Clients -
websub :
PublisherClient
The HTTP based client for WebSub topic registration and unregistration, and notifying the hub of new updates.
Constructor
__init
(string url, ClientConfiguration? config)
- url string
-
The URL to publish/notify updates
- config ClientConfiguration? <ballerina/http:ClientConfiguration?> ()
-
The
http:ClientConfiguration
for the underlying client or else()
Remote Methods
registerTopic | Registers a topic in a Ballerina WebSub Hub against which subscribers can subscribe and the publisher will
publish updates.
|
unregisterTopic | Unregisters a topic in a Ballerina WebSub Hub.
|
publishUpdate | Publishes an update to a remote Ballerina WebSub Hub.
|
notifyUpdate | Notifies a remote WebSub Hub from which an update is available to fetch for hubs that require publishing to
happen as such.
|
error? registerTopic = websubHubClientEP->registerTopic("http://websubpubtopic.com");
Parameters
- topic string
-
The topic to register
-
Return Type
(error?) An
error
if an error occurred registering the topic or esle()
error? unregisterTopic = websubHubClientEP->unregisterTopic("http://websubpubtopic.com");
Parameters
- topic string
-
The topic to unregister
-
Return Type
(error?) An
error
if an error occurred unregistering the topic or else()
publishUpdate
(string topic, string | xml | json | byte[] | ReadableByteChannel payload, string? contentType, map? headers)
returns error? error? publishUpdate = websubHubClientEP->publishUpdate("http://websubpubtopic.com",{"action": "publish",
"mode": "remote-hub"});
Parameters
- topic string
-
The topic for which the update occurred
- payload string | xml | json | byte[] | ReadableByteChannel
-
The update payload
- contentType string? (default <string?> ())
-
The type of the update content to set as the
ContentType
header
- headers map? (default <map<string>?> ())
-
The headers that need to be set (if any)
-
Return Type
(error?) An
error
if an error occurred with the update or else()
error? notifyUpdate = websubHubClientEP->notifyUpdate("http://websubpubtopic.com");
Parameters
- topic string
-
The topic for which the update occurred
- headers map? (default <map<string>?> ())
-
The headers that need to be set (if any)
-
Return Type
(error?) An
error
if an error occurred with the notification or else()