2 * Copyright (C) 2021 Jonathan Rajotte <jonathan.rajotte-julien@efficios.com>
4 * SPDX-License-Identifier: LGPL-2.1-only
8 #ifndef LTTNG_FIRING_POLICY_H
9 #define LTTNG_FIRING_POLICY_H
12 #include <sys/types.h>
14 struct lttng_firing_policy
;
20 enum lttng_firing_policy_status
{
21 LTTNG_FIRING_POLICY_STATUS_OK
= 0,
22 LTTNG_FIRING_POLICY_STATUS_ERROR
= -1,
23 LTTNG_FIRING_POLICY_STATUS_UNKNOWN
= -2,
24 LTTNG_FIRING_POLICY_STATUS_INVALID
= -3,
25 LTTNG_FIRING_POLICY_STATUS_UNSET
= -4,
26 LTTNG_FIRING_POLICY_STATUS_UNSUPPORTED
= -5,
29 enum lttng_firing_policy_type
{
30 LTTNG_FIRING_POLICY_TYPE_UNKNOWN
= -1,
31 LTTNG_FIRING_POLICY_TYPE_EVERY_N
= 0,
32 LTTNG_FIRING_POLICY_TYPE_ONCE_AFTER_N
= 1,
36 * Get the type of a firing policy.
38 extern enum lttng_firing_policy_type
lttng_firing_policy_get_type(
39 const struct lttng_firing_policy
*policy
);
42 * Create a firing_policy of type `every n`.
44 * A `every n` firing policy will carry the execution of an action only when the
45 * action was ready for execution for a multiple of N.
47 * Returns a firing_policy object on success, NULL on error.
48 * firing_policy objects must be destroyed using the
49 * lttng_firing_policy_destroy() function.
51 extern struct lttng_firing_policy
*lttng_firing_policy_every_n_create(
55 * Get the interval of a every N firing policy.
57 * Returns LTTNG_FIRING_POLICY_STATUS_OK and a sets the interval.
58 * on success, LTTNG_FIRING_POLICY_STATUS_INVALID if an invalid
59 * parameter is passed.
61 extern enum lttng_firing_policy_status
lttng_firing_policy_every_n_get_interval(
62 const struct lttng_firing_policy
*policy
, uint64_t *interval
);
65 * Create a firing_policy of type `once after N`.
67 * A `once after N` firing policy will carry the execution of an action only
68 * when the action was ready for execution at least N times and will only be
71 * Returns a firing_policy object on success, NULL on error.
72 * firing_policy objects must be destroyed using the
73 * lttng_firing_policy_destroy() function.
75 extern struct lttng_firing_policy
*lttng_firing_policy_once_after_n_create(
79 * Get the threshold of a once after N firing policy.
81 * Returns LTTNG_FIRING_POLICY_STATUS_OK and sets the threshold.
82 * on success, LTTNG_FIRING_POLICY_STATUS_INVALID if an invalid
83 * parameter is passed.
85 extern enum lttng_firing_policy_status
86 lttng_firing_policy_once_after_n_get_threshold(
87 const struct lttng_firing_policy
*policy
, uint64_t *threshold
);
90 * Destroy (frees) a firing policy object.
92 extern void lttng_firing_policy_destroy(struct lttng_firing_policy
*policy
);
98 #endif /* LTTNG_FIRING_POLICY_H */