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 to

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 that 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.

Parameters

  • topic string
  • The topic to register

  • Return Type

    (error)
  • error if an error occurred registering the topic

unregisterTopic

(string topic)

returns error

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

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

  • headers map (default ())
  • The headers, if any, that need to be set

  • Return Type

    (error)
  • error if an error occurred with the update

notifyUpdate

(string topic, map headers)

returns error

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 (default ())
  • The headers, if any, that need to be set

  • Return Type

    (error)
  • error if an error occurred with the notification