2022-10-31 15:19:56 +01:00
|
|
|
@0xf8f8864ba0678056;
|
|
|
|
|
|
|
|
using CSharp = import "programming_language/csharp.capnp";
|
|
|
|
$CSharp.namespace("FabAccessAPI.Schema");
|
|
|
|
|
|
|
|
using import "/capnp/rpc.capnp".SturdyRef;
|
|
|
|
|
2022-11-01 11:03:26 +01:00
|
|
|
using import "persistent.capnp".Persistent;
|
2022-10-31 15:19:56 +01:00
|
|
|
using import "state.capnp".State;
|
2022-11-01 11:54:01 +01:00
|
|
|
using import "state.capnp".Update;
|
2022-10-31 15:19:56 +01:00
|
|
|
|
2022-11-01 12:11:53 +01:00
|
|
|
interface Claimable {
|
2022-10-31 15:19:56 +01:00
|
|
|
restore @0 ( sturdy :SturdyRef ) -> ( claim :Claim );
|
|
|
|
# Restore a previously saved SturdyRef pointing to a Claim
|
|
|
|
|
|
|
|
claim @1 () -> ( claim :Claim );
|
|
|
|
# returns NULL if the resource is *currently* not claimable.
|
|
|
|
# drop the returned claim capability to unclaim it.
|
|
|
|
}
|
|
|
|
|
2022-11-01 12:11:53 +01:00
|
|
|
interface Lockable {
|
|
|
|
restore @0 ( sturdy :SturdyRef ) -> ( lock :Lock );
|
|
|
|
# Restore a previously saved SturdyRef pointing to a Claim
|
|
|
|
|
2022-11-01 12:44:33 +01:00
|
|
|
lock @1 () -> ( lock :Lock );
|
2022-11-01 12:11:53 +01:00
|
|
|
# Take exclusive access to a resource, disowning all other claims on this resource.
|
|
|
|
#
|
|
|
|
# On resources that do not allow concurrent claims to exist this method behaves similar to
|
|
|
|
# `claim`, however it will also succeed if a resource is already claimed, disowning the previous
|
|
|
|
# claim. On resources that do allow concurrent claims this method will disown all current claims on a
|
|
|
|
# resource and prevent new claims from being granted until the returned Lock capability is
|
|
|
|
# dropped. A call to `lock` on a resource that is already locked will succeed, invalidating the former
|
|
|
|
# lock.
|
|
|
|
}
|
|
|
|
|
2022-10-31 15:19:56 +01:00
|
|
|
interface Claim extends (Persistent) {
|
2022-11-01 11:54:01 +01:00
|
|
|
update @0 ( update :Update ) -> ( error :Error );
|
2022-12-07 16:12:50 +01:00
|
|
|
# Atomically update a resource via a claim.
|
2022-11-01 11:54:01 +01:00
|
|
|
#
|
|
|
|
# The parameter `update` is a list of `UpdateValue` that specify a list of behaviours to be
|
|
|
|
# updated with the associated data. The format of this data depends on and is defined by the
|
|
|
|
# behaviour.
|
2022-12-07 16:12:50 +01:00
|
|
|
# An update call is atomic, if any one of the UpdateValue can not be applied
|
2022-11-01 11:54:01 +01:00
|
|
|
# the entire update call fails and is not applied. A client may send multiple update calls in
|
2022-12-07 16:12:50 +01:00
|
|
|
# parallel to opt out of the atomic behaviour of update. The ordering in which multiple
|
2022-11-01 11:54:01 +01:00
|
|
|
# update calls are applied is not specified, a client MUST NOT rely on updates happening in the
|
|
|
|
# order they are sent.
|
|
|
|
# The returned `error` is NULL if the update call succeeded.
|
|
|
|
interface Error {
|
|
|
|
|
|
|
|
}
|
2022-10-31 15:19:56 +01:00
|
|
|
}
|
2022-11-01 12:11:53 +01:00
|
|
|
|
|
|
|
interface Lock extends (Claim) {
|
|
|
|
# An exclusive claim on a resource. Only a single Lock may exist for any given resource.
|
|
|
|
|
|
|
|
downgrade @0 () -> ( claim :Claim );
|
|
|
|
# Downgrade a lock to a claim, allowing additional claims to be granted on resources that allow
|
2022-11-01 12:44:33 +01:00
|
|
|
# for concurrent access. Calling this capability will invalidate the Lock capability.
|
2022-11-01 12:11:53 +01:00
|
|
|
}
|