Warning |
---|
|
This specification is currently a draft under development. |
Subscription Event Protocol
The CloudOS Subscription Event Protocol provides an event based model for managing subscriptions between Personal Clouds. The current implementation of the protocol will create a symmetric relationship between both Personal Clouds. Cloud subscriptions are done in such a way that both the originating and target clouds end up with a unique event channel to the other that is specific to the purpose for the subscription.
Rulesets do not manage subscriptions directly, but rather rely on the CloudOS service to do it for them. Consequently, to use the Subscription Event Protocol the CloudOS service ruleset must be installed in the Personal Cloud for both the originator and target. The CloudOS service listens for certain events, manages subscriptions, and provides functions for getting information about subscriptions.
Events
Subscribe
The system:subscribe
event is used to create a channel between two Personal Clouds.
...
- The
channelName
attribute is a label associated with the subscription that should convey meaning to developer. The channelName
is only used as a component in the creation of the event channel identifier. If no channelName
is specified the value of "orphan" will be used. - The
namespace
attribute is provided as a means for the developer to group subscriptions within a single, or group, or applications. The namespace
is used to filter the list of subscriptions returned by the subscriptionList()
function. If no namespace
is specified the value of "shared" will be used. - The
relationship
attribute allows the developer to characterize the relationship between the originator and target clouds. The relationship
attribute should be specified as a pair of values separated by a dash (e.g. parent-child
, peer-peer
, master-slave
). The first value of the relationship attribute will be stored with the originating Personal Cloud subscription, the second value will be stored with the target Personal Cloud subscription. The relationship
attribute values are used to filter the list of subscriptions returned by the subscriptionList()
function. If no relationship is specified the value of "peer-peer" will be used. - The
targetChannel
attribute is the event channel identifier (ECI) for the target cloud to which the subscription is to be made. Usually, this is the well-known ECI (doorbell) for the target cloud. The well-known ECI provides a means for bootstrapping subscriptions between clouds.
The ruleset wishing to create the subscription signals the CloudOS to do so by raising the
system:subscribesubscribe
event. This is most often done in a rule postlude as shown in the following example:
Code Block |
---|
theme | Confluence |
---|
language | javascript |
---|
|
fired {
raise cloudos event subscribe
with channelName = "Coworkers Bob+Ted"
and namespace = "MyFriends"
and relationship = "friend-friend"
and targetChannel = "3f15b820-af7ffa7f-012f-4c6e-00163ebczzzz00163ebccdcd"
and _api = "sky";
} |
The CloudOS service raises the cloudos:subscriptionRequestAdded
event within to the originating cloud so that other rulesets can take action, if needed:
domain: cloudos
type: subscriptionRequestAdded
attributes: targetChannel
, backChannel
, namespace
, relationship
, channelName
target cloud:
Code Block |
---|
|
cloudos:subscriptionRequestAdded(targetChannel, backChannel, namespace, relationship, channelName) |
The backChannel
attribute contains an ECI for the originating cloud that the CloudOS service has created and will pass to the target cloud.
The following rule would be selected upon seeing the cloudos:subscriptionRequestAdded
event with appropriate values for the event attributes:
Code Block |
---|
theme | Confluence |
---|
language | javascript |
---|
|
rule |
receiveprocess_subscriptionRequestAdded {
select when cloudos subscriptionRequestAdded
namespace re/MyFriends/"
channelName re/Coworkers Bob+Ted/
relationship re/friend-friend/
...
} |
The CloudOS services in the target cloud raises the cloudos:subscriptionRequestPending
to signal the receipt of a pending subscription request:
domain: cloudos
type: subscriptionRequestPending
attributes: eventChannel
, namespace
, relationship
, channelName
Code Block |
---|
|
cloudos:subscriptionRequestPending(eventChannel, namespace, relationship, channelName) |
Subscription Approval or Rejection
With the subscription request pending approval, the Personal Cloud which received the request target cloud can either approve or reject the request.
Approval
To approve the subscription request the following event should be raised:
domain: cloudostype: subscriptionRequestApprovedattributes: eventChannela ruleset in the the target cloud raises the cloudos:subscriptionRequestApproved
event to signal the CloudOS service that the subscription is approved:
Code Block |
---|
|
cloudos:subscriptionRequestApproved(eventChannel) |
For example, the following postlude would raise the cloudos:subscriptionRequestApproved
event:
Code Block |
---|
theme | Confluence |
---|
language | javascript |
---|
|
fired {
raise cloudos event subscriptionRequestApproved
with eventChannel = "3f15b820-af7f-012f-4c6e-00163ebcaaaa"
and _api = "sky";
} |
Once the subscription request is approved
both Personal Clouds will receive a callback events raised within each respective Personal Cloud. These events are raised to enable the developer to take additional actions when the Personal Channels are actually created.- domain: cloudos
- type: CloudOS_subscriptionAdded
- attributes: eventChannel, backChannel, namespace, relationship, channelName
, the CloudOS service in both the orginating and target clouds will raise the cloudos:CloudOS_subscriptionAdded
event so that a ruleset can take additional actions once the subscription has been created
Code Block |
---|
|
cloudos:CloudOS_subscriptionAdded(eventChannel, backChannel, namespace, relationship, channelName) |
The following shows a rule that is selected when the cloudos:CloudOS_subscriptionAdded event
is raised:
Code Block |
---|
theme | Confluence |
---|
language | javascript |
---|
|
rule receiveprocess_subscriptionRequestAdded {
select when cloudos subscriptionRequestAdded
namespace re/MyFriends/
channelName re/Coworkers Bob+Ted/
relationship re/friend-friend/ |
Rejection
To reject the subscription request the following event should be raised:
- domain: cloudos
- type: subscriptionRequestRejected
- attributes: eventChannel
Code Block |
---|
theme | Confluence |
---|
language | javascript |
---|
|
fired {
raise cloudos event subscriptionRequestRejected
with eventChannel = "3f15b820-af7f-012f-4c6e-00163ebcaaaa"
and _api = "sky";
} |
When the subscription request is rejected the following event will be raised with the Personal Cloud:
- domain: cloudos
- type: subscriptionRejected
- attributes: eventChannel, namespace, relationship, channelName
Code Block |
---|
theme | Confluence |
---|
language | javascript |
---|
|
rule receive_subscriptionRejected
select when cloudos subscriptionRejected
namespace re/MyFriends/
channelName re/Coworkers Bob+Ted/
relationship re/friend-friend/ |
And the following event will be raised in the Personal Cloud which made the subscription request:
- domain: cloudos
- type: subscriptionRejected
- attributes: backChannel, namespace, relationship, channelName
Code Block |
---|
theme | Confluence |
---|
language | javascript |
---|
|
rule receive_subscriptionRejected
select when cloudos subscriptionRejected
namespace re/MyFriends/
channelName re/Coworkers Bob+Ted/
relationship re/friend-friend/ |
...
- domain: cloudos
- type: CloudOS_subscriptionRemoved
- attributes: eventChannel, backChannel, namespace, relationship, channelName
Code Block |
---|
theme | Confluence |
---|
language | javascript |
---|
|
rule receive_CloudOS_subscriptionRemoved
select when cloudos CloudOS_subscriptionRemoved
namespace re/MyFriends/
channelName re/Coworkers Bob+Ted/
relationship re/friend-friend/ |
Functions
subscriptionList(namespace, relationship)
...