api.fabaccess-api/notify.capnp

45 lines
1.7 KiB
Cap'n Proto
Raw Permalink Normal View History

2022-10-31 15:19:56 +01:00
@0xc0787ef6e3cb87e1;
using CSharp = import "programming_language/csharp.capnp";
$CSharp.namespace("FabAccessAPI.Schema");
using import "resource.capnp".Resource;
using import "utils.capnp".OID;
using import "utils.capnp".Map;
2024-03-01 15:39:30 +01:00
using import "state.capnp".Update;
2024-04-16 15:03:10 +02:00
using import "measure.capnp".Measurement;
2022-10-31 15:19:56 +01:00
interface Notifiable {
2024-04-22 11:00:27 +02:00
state @0 () -> Map(OID, AnyPointer);
2022-11-01 11:54:01 +01:00
# Returns the current state of a resource.
2024-04-22 11:00:27 +02:00
getStateOid @4 ( oid :OID ) -> ( state :AnyPointer );
2024-04-16 15:54:47 +02:00
# Return only the state of the trait with the given OID
subscribe @1 ( subscriber :Subscriber(Update) ) -> ( subscription :Subscription );
2022-11-01 11:54:01 +01:00
# Subscribe to state updates. The passed in `subscriber` is an interface implemented on the
# client side that a server calls to send update notifications.
2024-04-15 16:28:23 +02:00
2024-04-22 11:00:27 +02:00
measurements @2 () -> Map(OID, AnyPointer);
2024-04-15 16:28:23 +02:00
subscribeMeasurements @3 ( subscriber :Subscriber(Measurement) ) -> ( subscription: Subscription );
2022-10-31 15:19:56 +01:00
}
interface Subscriber(Update) {
2024-03-01 15:39:30 +01:00
update @0 ( update :Update ) -> UpdateResult;
2022-11-01 11:54:01 +01:00
# Called by a server when a new state was produced for this resource. This method MAY not be
# called when a resource was updated but did not change its state. A server will only ever have
# one running update call per client session, so a client can limit the rate of updates by not
# resolving this call immediately. A server will coalesce multiple updates into a single update
# notification, meaning a client is not guaranteed to receive every intermediary state for a
# resource.
2022-10-31 15:19:56 +01:00
}
2024-04-15 16:28:23 +02:00
2024-03-01 15:39:30 +01:00
struct UpdateResult { } # Empty struct to make `update` apply backpressure.
interface Subscription {
cancel @0 (); # Cancel this subscription, making the server not send anymore updates.
}