vintage_net v0.7.7 VintageNet.PropertyTable View Source
PropertyTables are in-memory key-value stores
Users can subscribe to keys or groups of keys to be notified of changes.
Keys are hierarchically layed out with each key being represented as a list
for the path to the key. For example, to get the current state of the network
interface eth0
, you would get the value of the key, ["net", "ethernet", "eth0"]
.
Values can be any Elixir data structure except for nil
. nil
is used to
identify non-existent keys. Therefore, setting a property to nil
deletes
the property.
Users can get and listen for changes in multiple keys by specifying prefix paths. For example, if you wants to get every network property, run:
PropertyTable.get_by_prefix(table, ["net"])
Likewise, you can subscribe to changes in the network status by running:
PropertyTable.subscribe(table, ["net"])
Properties can include metadata. PropertyTable
only specifies that metadata
is a map.
Link to this section Summary
Functions
Returns a specification to start a property_table under a supervisor.
See Supervisor
.
Clear out a property
Clear out all properties under a prefix
Fetch a property with the time that it was set
Get the current value of a property
Get a list of all properties matching the specified prefix
Get a list of all properties matching the specified prefix
Update a property and notify listeners
Subscribe to receive events
Stop subscribing to a property
Link to this section Types
Properties
property_with_wildcards()
View Sourceproperty_with_wildcards() :: [String.t() | :_]
A table_id identifies a group of properties
Link to this section Functions
Returns a specification to start a property_table under a supervisor.
See Supervisor
.
Clear out a property
Clear out all properties under a prefix
Fetch a property with the time that it was set
Timestamps come from :erlang.monotonic_time()
Get the current value of a property
Get a list of all properties matching the specified prefix
match(table, pattern)
View Sourcematch(table_id(), property_with_wildcards()) :: [{property(), value()}]
Get a list of all properties matching the specified prefix
Update a property and notify listeners
subscribe(table, name)
View Sourcesubscribe(table_id(), property_with_wildcards()) :: :ok
Subscribe to receive events
unsubscribe(table, name)
View Sourceunsubscribe(table_id(), property_with_wildcards()) :: :ok
Stop subscribing to a property