Clients -
websub :
Client
The HTTP based Caller remote functions for outbound WebSub Subscription, Unsubscription, Registration, Unregistration and Notification requests to a Hub.
Constructor
__init
(string url, ClientEndpointConfig? config)
- url string
- config ClientEndpointConfig? ()
Remote Methods
Sends a subscription request to a WebSub Hub.
Sends an unsubscription request to a WebSub Hub.
Registers a topic in a Ballerina WebSub Hub against which subscribers can subscribe and the publisher will publish updates.
Unregisters a topic in a Ballerina WebSub Hub.
Publishes an update to a remote Ballerina WebSub Hub.
Notifies a remote WebSub Hub that an update is available to fetch, for hubs that require publishing to happen as such.
Fields
- hubUrl string
-
The URL of the target Hub to which requests need to be sent
subscribe
(SubscriptionChangeRequest subscriptionRequest)
returns SubscriptionChangeResponse | errorSends a subscription request to a WebSub Hub.
Parameters
- subscriptionRequest SubscriptionChangeRequest
-
The
SubscriptionChangeRequest
containing subscription details
-
Return Type
(SubscriptionChangeResponse | error) SubscriptionChangeResponse
indicating subscription details, if the request was successful elseerror
if an error occurred with the subscription request
unsubscribe
(SubscriptionChangeRequest unsubscriptionRequest)
returns SubscriptionChangeResponse | errorSends an unsubscription request to a WebSub Hub.
Parameters
- unsubscriptionRequest SubscriptionChangeRequest
-
The
SubscriptionChangeRequest
containing unsubscription details
-
Return Type
(SubscriptionChangeResponse | error) SubscriptionChangeResponse
indicating unsubscription details, if the request was successful elseerror
if an error occurred with the unsubscription request
Registers a topic in a Ballerina WebSub Hub against which subscribers can subscribe and the publisher will publish updates.
Parameters
- topic string
-
The topic to register
-
Return Type
(error?) error
if an error occurred registering the topic
Unregisters a topic in a Ballerina WebSub Hub.
Parameters
- topic string
-
The topic to unregister
-
Return Type
(error?) error
if an error occurred unregistering the topic
publishUpdate
(string topic, string | xml | json | byte[] | ReadableByteChannel payload, string? contentType, map? headers)
returns error?Publishes an update to a remote Ballerina WebSub Hub.
Parameters
- topic string
-
The topic for which the update occurred
- payload string | xml | json | byte[] | ReadableByteChannel
-
The update payload
- contentType string? - ()
-
The type of the update content, to set as the
ContentType
header
- headers map? - ()
-
The headers, if any, that need to be set
-
Return Type
(error?) error
if an error occurred with the update
Notifies a remote WebSub Hub that an update is available to fetch, for hubs that require publishing to happen as such.
Parameters
- topic string
-
The topic for which the update occurred
- headers map? - ()
-
The headers, if any, that need to be set
-
Return Type
(error?) error
if an error occurred with the notification