websub
Module websub
API
Declarations
Definitions
ayeshalm/websub
Clients
websub: DiscoveryService
Represents resource-discovery service which identify the hub
and topic
from resource-URL
.
Constructor
Invoked during the initialization of a websub:DiscoveryService
init (string discoveryUrl, ClientConfiguration? publisherClientConfig)
- discoveryUrl string -
- publisherClientConfig ClientConfiguration? - {@code http:ClientConfiguration} if present to be used to initialize underlying {@code http:Client}
discoverResourceUrls
function discoverResourceUrls(string?|string[] expectedMediaTypes, string?|string[] expectedLanguageTypes) returns [string, string]|error
Discovers the hub and topic URLs defined by a resource URL.
Parameters
websub: SubscriptionClient
The HTTP based client for WebSub subscription and unsubscription.
Constructor
Initializes the websub:SubscriptionClient
.
init (string url, *ClientConfiguration config)
- url string - The URL at which the subscription should be changed
- config *ClientConfiguration - The
http:ClientConfiguration
for the underlying client or()
subscribe
function subscribe(SubscriptionChangeRequest subscriptionRequest) returns SubscriptionChangeResponse|error
Sends a subscription request to a WebSub Hub.
websub:SubscriptionChangeResponse|error response = websubHubClientEP->subscribe(subscriptionRequest);
Parameters
- subscriptionRequest SubscriptionChangeRequest - The
SubscriptionChangeRequest
containing the subscription details
Return Type
- SubscriptionChangeResponse|error - The
SubscriptionChangeResponse
indicating subscription details if the request was successful or else anerror
if an error occurred with the subscription request
unsubscribe
function unsubscribe(SubscriptionChangeRequest unsubscriptionRequest) returns SubscriptionChangeResponse|error
Sends an unsubscription request to a WebSub Hub.
websub:SubscriptionChangeResponse|error response = websubHubClientEP->unsubscribe(subscriptionRequest);
Parameters
- unsubscriptionRequest SubscriptionChangeRequest - The
SubscriptionChangeRequest
containing unsubscription details
Return Type
- SubscriptionChangeResponse|error - An unsubscription details if the request was successful or else an
error
if an error occurred with the unsubscription request
Listeners
websub: Listener
Represents a Subscriber Service listener endpoint.
Constructor
Invoked during the initialization of a websub:Listener
. Either an http:Listener
or a port number must be
provided to initialize the listener.
init (int|Listener listenTo, *ListenerConfiguration config)
- config *ListenerConfiguration -
websub:ListenerConfiguration
to be provided to underlying HTTP Listener
attach
function attach(SubscriberService subscriberService, string[]|string? name) returns error?
Attaches the provided Service to the Listener.
Parameters
- subscriberService SubscriberService - The
websub:SubscriberService
object to attach
Return Type
- error? - An
error
, if an error occurred during the service attaching process
attachWithConfig
function attachWithConfig(SubscriberService subscriberService, SubscriberServiceConfiguration configuration, string[]|string? name) returns error?
Setup the provided Service with given configurations and attaches it to the listener
Parameters
- subscriberService SubscriberService - The
websub:SubscriberService
object to attach
- configuration SubscriberServiceConfiguration -
SubscriberServiceConfiguration
which should be incorporated into the provided Service
Return Type
- error? - An
error
, if an error occurred during the service attaching process
detach
function detach(SubscriberService s) returns error?
Detaches the provided Service from the Listener.
Parameters
- s SubscriberService - The service to be detached
Return Type
- error? - An
error
, if an error occurred during the service detaching process
'start
function 'start() returns error?
Starts the attached Service.
Return Type
- error? - An
error
, if an error occurred during the listener starting process
gracefulStop
function gracefulStop() returns error?
Gracefully stops the hub listener. Already accepted requests will be served before the connection closure.
Return Type
- error? - An
error
, if an error occurred during the listener stopping process
immediateStop
function immediateStop() returns error?
Stops the service listener immediately. It is not implemented yet.
Return Type
- error? - An
error
, if an error occurred during the listener stopping process
Annotations
websub: SubscriberServiceConfig
WebSub Subscriber Configuration for the service, indicating subscription related parameters.
Records
websub: Acknowledgement
Record representing the subscription-denial / content-distribution acknowledgement
Fields
- Fields Included from *CommonResponse
- headers map<string|string[]>
- body map<string>
websub: ContentDistributionMessage
Record representing the content-distribution request.
Fields
- contentType string?(default ()) - content-type header value of the original
http:Request
websub: ListenerConfiguration
Provides a set of configurations for configure the underlying HTTP listener of the WebSub listener.
Fields
- Fields Included from *ListenerConfiguration
- host string
- http1Settings ListenerHttp1Settings
- secureSocket ballerina/http:1.1.0-alpha8:ListenerSecureSocket?
- httpVersion string
- timeout decimal
- server string?
- requestLimits RequestLimitConfigs
websub: SubscriberServiceConfiguration
Configuration for a WebSubSubscriber service.
Fields
- leaseSeconds int? - The period for which the subscription is expected to be active
- callback string? - The callback URL for subscriber-service
- secret string? - The secret to be used for authenticated content distribution
- appendServiceUrl boolean(default false) - This flag notifies whether or not to append service-path to callback-url
- httpConfig ClientConfiguration? - The configuration for the hub client used to interact with the discovered/specified hub
- discoveryConfig record {| string|string[] accept?; string|string[] acceptLanguage?; http:ClientConfiguration httpConfig?; |} ? - HTTP client configurations for resource discovery
websub: SubscriptionChangeRequest
Record representing a WebSub subscription change request-body.
Fields
- topic string(default "") - The topic for which the subscription/unsubscription request is sent
- callback string(default "") - The callback which should be registered/unregistered for the subscription/unsubscription request sent
- leaseSeconds int(default 0) - The lease period for which the subscription is expected to be active
- secret string(default "") - The secret to be used for authenticated content distribution with this subscription
websub: SubscriptionChangeResponse
Record representing subscription/unsubscription details if a subscription/unsubscription request is successful.
Fields
- hub string(default "") - The hub at which the subscription/unsubscription was successful
- topic string(default "") - The topic for which the subscription/unsubscription was successful
- response Response - The response from the hub to the subscription/unsubscription request
websub: SubscriptionVerification
Record representing the subscription / unsubscription intent verification request-body.
Fields
- hubMode string - current hub.mode parameter (subscribe / unsubscribe)
- hubTopic string - topic URL
- hubChallenge string - hub.challenge parameter used for verification
- hubLeaseSeconds string - hub.lease_seconds parameter used to validate the expiration of subscription
websub: SubscriptionVerificationSuccess
Record representing the subscription / unsubscription intent verification success.
Fields
- Fields Included from *CommonResponse
- headers map<string|string[]>
- body map<string>
Errors
websub: Error
Represents a webSub distinct error.
websub: ListenerError
Represents a listener errors.
websub: ResourceDiscoveryFailedError
Represents a resource-discovery failed error.
websub: ServiceExecutionError
Represents a websubhub service execution error.
websub: SubscriptionDeletedError
Represents the subscription-delete action from the subscriber
websub: SubscriptionDeniedError
Represents a subscription denied error.
websub: SubscriptionInitiationFailedError
Represents a subscription-initiation failed error.
websub: SubscriptionVerificationError
Represents a subscription-verificatation error.
Object types
websub: SubscriberService
The WebSub service type
Import
import ayeshalm/websub;
Metadata
Released date: over 3 years ago
Version: 1.2.0-alpha8-fix2
Compatibility
Platform: java11
Ballerina version: slalpha5
Pull count
Total: 11
Current verison: 2
Weekly downloads
Other versions
Dependencies