pubsub

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPConfig added in v1.0.1

type HTTPConfig struct {
	// Port to listen on
	Port int
	// Path for HTTP broadast
	Path string
	// Secret token to authorize requests
	Secret string
}

HTTPConfig contains HTTP pubsub adapter configuration

func NewHTTPConfig added in v1.0.1

func NewHTTPConfig() HTTPConfig

NewHTTPConfig builds a new config for HTTP pub/sub

type HTTPSubscriber added in v1.0.1

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

HTTPSubscriber represents HTTP pub/sub

func NewHTTPSubscriber added in v1.0.1

func NewHTTPSubscriber(node Handler, config *HTTPConfig) *HTTPSubscriber

NewHTTPSubscriber builds a new HTTPSubscriber struct

func (*HTTPSubscriber) Handler added in v1.0.1

func (s *HTTPSubscriber) Handler(w http.ResponseWriter, r *http.Request)

Handler processes HTTP requests

func (*HTTPSubscriber) Shutdown added in v1.0.1

func (s *HTTPSubscriber) Shutdown() error

Shutdown stops the HTTP server

func (*HTTPSubscriber) Start added in v1.0.1

func (s *HTTPSubscriber) Start() error

Start creates an HTTP server or attaches a handler to the existing one

type Handler added in v1.1.4

type Handler interface {
	HandlePubSub(json []byte)
}

type RedisConfig added in v1.0.1

type RedisConfig struct {
	// Redis instance URL or master name in case of sentinels usage
	URL string
	// Redis channel to subscribe to
	Channel string
	// List of Redis Sentinel addresses
	Sentinels string
	// Redis Sentinel discovery interval (seconds)
	SentinelDiscoveryInterval int
	// Redis keepalive ping interval (seconds)
	KeepalivePingInterval int
}

RedisConfig contains Redis pubsub adapter configuration

func NewRedisConfig added in v1.0.1

func NewRedisConfig() RedisConfig

NewRedisConfig builds a new config for Redis pubsub

type RedisSubscriber

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

RedisSubscriber contains information about Redis pubsub connection

func NewRedisSubscriber

func NewRedisSubscriber(node Handler, config *RedisConfig) *RedisSubscriber

NewRedisSubscriber returns new RedisSubscriber struct

func (*RedisSubscriber) Shutdown added in v1.0.1

func (s *RedisSubscriber) Shutdown() error

Shutdown is no-op for Redis

func (*RedisSubscriber) Start

func (s *RedisSubscriber) Start() error

Start connects to Redis and subscribes to the pubsub channel if sentinels is set it gets the the master address first

type Subscriber added in v1.0.1

type Subscriber interface {
	Start() error
	Shutdown() error
}

Subscriber is responsible for receiving broadcast messages and sending them to hub

func NewSubscriber added in v1.0.1

func NewSubscriber(node Handler, adapter string, redis *RedisConfig, http *HTTPConfig) (Subscriber, error)

NewSubscriber creates an instance of the provided adapter

Jump to

Keyboard shortcuts

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