econfd_notif Module

An Erlang interface equivalent to the event notifications C-API, (documented in confd_lib_events(3)).

Types

notif_option/0

-type notif_option() ::
          {heartbeat_interval, integer()} |
          {health_check_interval, integer()} |
          {stream_name, atom()} |
          {start_time, econfd:datetime()} |
          {stop_time, econfd:datetime()} |
          {xpath_filter, binary()} |
          {usid, integer()} |
          {verbosity, 0..3}.

Related types: econfd:datetime()

-------------------------------------------------------------------- External functions --------------------------------------------------------------------

notification/0

-type notification() ::
          #econfd_notif_audit{} |
          #econfd_notif_syslog{} |
          #econfd_notif_commit_simple{} |
          #econfd_notif_commit_diff{} |
          #econfd_notif_user_session{} |
          #econfd_notif_ha{} |
          #econfd_notif_subagent_info{} |
          #econfd_notif_commit_failed{} |
          #econfd_notif_snmpa{} |
          #econfd_notif_forward_info{} |
          #econfd_notif_confirmed_commit{} |
          #econfd_notif_upgrade{} |
          #econfd_notif_progress{} |
          #econfd_notif_stream_event{} |
          #econfd_notif_confd_compaction{} |
          #econfd_notif_ncs_cq_progress{} |
          #econfd_notif_ncs_audit_network{} |
          confd_heartbeat | confd_health_check | confd_reopen_logs |
          ncs_package_reload.

Functions

close/1

-spec close(Socket) -> Result
               when
                   Socket :: econfd:socket(),
                   Result :: ok | {error, econfd:error_reason()}.

Related types: econfd:error_reason(), econfd:socket()

Close the event notification connection.

connect/2

-spec connect(Path, Mask) -> econfd:connect_result()
                 when Path :: string(), Mask :: integer();
             (Address, Mask) -> econfd:connect_result()
                 when Address :: econfd:ip(), Mask :: integer().

Related types: econfd:connect_result(), econfd:ip()

connect/3

-spec connect(Path, Mask, Options) -> econfd:connect_result()
                 when
                     Path :: string(),
                     Mask :: integer(),
                     Options :: [notif_option()];
             (Address, Port, Mask) -> econfd:connect_result()
                 when
                     Address :: econfd:ip(),
                     Port :: non_neg_integer(),
                     Mask :: integer().

Related types: notif_option(), econfd:connect_result(), econfd:ip()

connect/4

connect(Address, Port, Mask, Options)

do_connect/3

-spec do_connect(Address, Mask, Options) -> econfd:connect_result()
                    when
                        Address ::
                            #econfd_conn_ip{} | #econfd_conn_local{},
                        Mask :: integer(),
                        Options :: [Option].

Related types: econfd:connect_result()

Connect to the notif server.

handle_notif/1

-spec handle_notif(Notif) -> notification()
                      when Notif :: binary() | term().

Related types: notification()

Decode the notif message and return corresponding record depending on the type of the message.

It is the resposibility of the application to read data from the notifications socket.

maybe_element/2

maybe_element(N, Tuple)

notification_done/2

-spec notification_done(Socket, Thandle) -> Result
                           when
                               Socket :: econfd:socket(),
                               Thandle :: integer(),
                               Result ::
                                   ok | {error, econfd:error_reason()}.

Related types: econfd:error_reason(), econfd:socket()

Indicate that we're done with diff processing.

Whenever we subscribe to ?CONFD_NOTIF_COMMIT_DIFF we must indicate to confd that we're done with the diff processing. The transaction hangs until we've done this.

notification_done/3

-spec notification_done(Socket, Usid, NotifType) -> Result
                           when
                               Socket :: econfd:socket(),
                               Usid :: integer(),
                               NotifType :: audit | audit_network,
                               Result ::
                                   ok | {error, econfd:error_reason()}.

Related types: econfd:error_reason(), econfd:socket()

Indicate that we're done with notif processing.

When we subscribe to ?CONFD_NOTIF_AUDIT with ?CONFD_NOTIF_AUDIT_SYNC or to ?NCS_NOTIF_AUDIT_NETWORK with ?NCS_NOTIF_AUDIT_NETWORK_SYNC, we must indicate that we're done with the notif processing. The user-session hangs until we've done this.

recv/1

recv(Socket)

Equivalent to recv(Socket, infinity).

recv/2

-spec recv(Socket, Timeout) -> Result
              when
                  Socket :: econfd:socket(),
                  Timeout :: non_neg_integer() | infinity,
                  Result ::
                      {ok, notification()} |
                      {error, econfd:transport_error()} |
                      {error, econfd:error_reason()}.

Related types: notification(), econfd:error_reason(), econfd:socket(), econfd:transport_error()

Wait for an event notification message and return corresponding record depending on the type of the message.

The logno element in the record is an integer. These integers can be used as an index to the function econfd_logsyms:get_logsym/1 in order to get a textual description for the event.

When recv/2 returns {error, timeout} the connection (and its event subscriptions) is still active and the application needs to call recv/2 again. But if recv/2 returns {error, Reason} the connection to ConfD is closed and all event subscriptions associated with it are cleared.

unpack_ha_node/1

unpack_ha_node(_)

Last updated

Was this helpful?