Help us shape the future of Go! Take the 2026 Go Developer Survey

webnotifier

package
v0.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 15 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareTopicMessage added in v0.1.5

func PrepareTopicMessage(topic string, message []byte) ([]byte, error)

PrepareTopicMessage prepares topic message.

Types

type Action added in v0.1.4

type Action struct {
	ProtocolName string                 `json:",omitempty"`
	Message      service.DIDCommMsgMap  `json:",omitempty"`
	Properties   map[string]interface{} `json:",omitempty"`
}

Action represents service.DIDCommAction.

type HTTPNotifier

type HTTPNotifier struct {
	// contains filtered or unexported fields
}

HTTPNotifier is a webhook dispatcher capable of notifying multiple subscribers via HTTP.

func NewHTTPNotifier

func NewHTTPNotifier(webhookURLs []string) *HTTPNotifier

NewHTTPNotifier returns a new instance of an HTTPNotifier.

func (*HTTPNotifier) Notify

func (n *HTTPNotifier) Notify(topic string, message []byte) error

Notify sends the given message to all of the urls. Topic is appended to the end of the webhook (subscriber) URL. E.g. localhost:8080/topic If multiple errors are encountered, then the first one is returned.

type Notifier added in v0.1.4

type Notifier interface {
	Notify(topic string, message []byte) error
}

Notifier represents a notification dispatcher.

type Observer added in v0.1.4

type Observer struct {
	// contains filtered or unexported fields
}

Observer instance.

func NewObserver added in v0.1.4

func NewObserver(notifier Notifier) *Observer

NewObserver returns observer.

func (*Observer) RegisterAction added in v0.1.4

func (o *Observer) RegisterAction(topic string, ch <-chan service.DIDCommAction)

RegisterAction registers action channel to observer events.

func (*Observer) RegisterStateMsg added in v0.1.4

func (o *Observer) RegisterStateMsg(topic string, ch <-chan service.StateMsg)

RegisterStateMsg registers state channel to observer events.

type StateMsg added in v0.1.4

type StateMsg struct {
	ProtocolName string                 `json:",omitempty"`
	Type         string                 `json:",omitempty"`
	StateID      string                 `json:",omitempty"`
	Message      service.DIDCommMsgMap  `json:",omitempty"`
	Properties   map[string]interface{} `json:",omitempty"`
}

StateMsg represents service.StateMsg.

type WSNotifier

type WSNotifier struct {
	// contains filtered or unexported fields
}

WSNotifier is a dispatcher capable of notifying multiple subscribers via WebSocket.

func NewWSNotifier

func NewWSNotifier(path string) *WSNotifier

NewWSNotifier returns a new instance of an WSNotifier.

func (*WSNotifier) GetRESTHandlers

func (n *WSNotifier) GetRESTHandlers() []rest.Handler

GetRESTHandlers returns all REST handlers provided by notifier.

func (*WSNotifier) Notify

func (n *WSNotifier) Notify(topic string, message []byte) error

Notify sends the given message to all of the WS clients. If multiple errors are encountered, then the first one is returned.

type WebNotifier

type WebNotifier struct {
	// contains filtered or unexported fields
}

WebNotifier is a dispatcher capable of notifying multiple subscribers via HTTP Webhooks and WebSockets.

func New

func New(wsPath string, webhookURLs []string) *WebNotifier

New returns a new instance of a WebNotifier.

func (*WebNotifier) GetRESTHandlers

func (n *WebNotifier) GetRESTHandlers() []rest.Handler

GetRESTHandlers returns all REST handlers provided by notifier.

func (*WebNotifier) Notify

func (n *WebNotifier) Notify(topic string, message []byte) error

Notify sends the given message to all of the subscribers. If multiple errors are encountered, then the first one is returned.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL