This API documentation is for Ballerina 1.2.0. View API documentation for the latest release.

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? ()
  • 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.

registerTopic

(string topic)

returns error?

Registers a topic in a Ballerina WebSub Hub against which subscribers can subscribe and the publisher will publish updates.

 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 ()

unregisterTopic

(string topic)

returns error?

Unregisters a topic in a Ballerina WebSub Hub.

 error? unregisterTopic = websubHubClientEP->unregisterTopic("http://websubpubtopic.com");

Parameters

  • topic string
  • The topic to unregister

  • Return Type

    (error?)
  • An errorif an error occurred unregistering the topic or else ()

publishUpdate

(string topic, string | xml | json | byte[] | ReadableByteChannel payload, string? contentType, map<string> headers)

returns error?

Publishes an update to a remote Ballerina WebSub Hub.

 error? publishUpdate = websubHubClientEP->publishUpdate("http://websubpubtopic.com",{"action": "publish",
 "mode": "remote-hub"});

Parameters

  • topic string
  • The topic for which the update occurred

  • contentType string? (default ())
  • The type of the update content to set as the ContentType header

  • headers map<string> (default ())
  • The headers that need to be set (if any)

  • Return Type

    (error?)
  • An errorif an error occurred with the update or else ()

notifyUpdate

(string topic, map<string> headers)

returns error?

Notifies a remote WebSub Hub from which an update is available to fetch for hubs that require publishing to happen as such.

  error? notifyUpdate = websubHubClientEP->notifyUpdate("http://websubpubtopic.com");

Parameters

  • topic string
  • The topic for which the update occurred

  • headers map<string> (default ())
  • The headers that need to be set (if any)

  • Return Type

    (error?)
  • An errorif an error occurred with the notification or else ()