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)

Remote Methods

Fields

  • hubUrl string
  • The URL of the target Hub to which requests need to be sent

subscribe

(SubscriptionChangeRequest subscriptionRequest)

returns SubscriptionChangeResponse | error

Sends a subscription request to a WebSub Hub.

Parameters

  • Return Type

    (SubscriptionChangeResponse | error)
  • SubscriptionChangeResponse indicating subscription details, if the request was successful else error if an error occurred with the subscription request

unsubscribe

(SubscriptionChangeRequest unsubscriptionRequest)

returns SubscriptionChangeResponse | error

Sends an unsubscription request to a WebSub Hub.

Parameters

  • Return Type

    (SubscriptionChangeResponse | error)
  • SubscriptionChangeResponse indicating unsubscription details, if the request was successful else error if an error occurred with the unsubscription request

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

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

  • Return Type

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