Module esysevent

Subscribes to system event channels on illumos.

Description

Subscribes to system event channels on illumos

This module will only compile and run on illumos/Solaris systems.

The most common use of this module is to subscribe to notifications about zone status changes, with channel com.sun:zones:status.

Example:

  1> {ok, Hdl, MsgRef} = esysevent:evc_subscribe("com.sun:zones:status", [], "testing", all).
  {ok,#Ref<0.2937418369.3205890050.177596>,
      #Ref<0.2937418369.3205758978.177595>}
  2> flush().
  Shell got {sysevent,#Ref<0.2937418369.3205758978.177595>,
                      #{class => <<"status">>,seq => 172,
                        subclass => <<"change">>,time => 4745966022729317},
                      #{<<"newstate">> => {string,<<"initialized">>},
                        <<"oldstate">> => {string,<<"uninitialized">>},
                        <<"when">> => {uint64,4745966022720511},
                        <<"zoneid">> => {int32,1},
                        <<"zonename">> => {string,<<"testzone">>}}}
  

Data Types

bind_flags()

bind_flags() = [create | hold_pending | hold_pending_indefinitely]

channel()

channel() = iolist()

String, e.g. com.sun:zones:status

class()

class() = all | iolist()

Class name

err_result()

err_result() = {error, {func(), errno(), string()}} | {error, term()}

errno()

errno() = integer()

System errno value

ev_attrs()

ev_attrs() = nvlist()

ev_info()

ev_info() = #{class => binary(), subclass => binary(), seq => integer(), time => integer()}

event_msg()

event_msg() = {sysevent, msgref(), ev_info(), ev_attrs()}

Format of a message received by an event subscriber.

func()

func() = atom()

handle()

handle() = reference()

Reference to an EVC handle. Note that if this term gets garbage-collected, the subscription will be automatically cancelled. Subscribers are advised to store it in process state until it is no longer required.

msgref()

msgref() = reference()

Unique reference included in event messages for a given subscription

nv_int_type()

nv_int_type() = byte | int8 | uint8 | int16 | uint16 | int32 | uint32 | int64 | uint64

nv_val()

nv_val() = {boolean, boolean()} | {nv_int_type(), integer()} | {string, iolist()} | {array, nv_int_type(), [integer()]} | {array, boolean, [boolean()]} | {array, string, [iolist()]} | {hrtime, integer()} | {nvlist, nvlist()} | {array, nvlist, [nvlist()]}

nvlist()

nvlist() = #{binary() => nv_val()}

The general format of an nvlist_t, converted to an Erlang map.

subid()

subid() = iolist()

Subscriber name, needs to be unique (include PID or something random)

Function Index

evc_subscribe/4Subscribe to an event channel.
evc_unsubscribe/1Cancel a subscription to an event channel.

Function Details

evc_subscribe/4

evc_subscribe(Channel::channel(), BindFlags::bind_flags(), SubId::subid(), Class::class()) -> {ok, handle(), msgref()} | err_result()

Subscribe to an event channel

This will set up the event channel to produce messages targetted at the process which called this function. The msgref() term returned matches the one included in the messages for this specific subscription. Event messages have the format shown in type event_msg().

See also: bind_flags(), channel(), class(), event_msg(), handle(), subid().

evc_unsubscribe/1

evc_unsubscribe(Handle::handle()) -> ok | err_result()

Cancel a subscription to an event channel

After this function returns OK, no further new messages for the subscription will be enqueued for the owning process.

See also: handle().


Generated by EDoc