broker

package
v2.0.437+incompatible Latest Latest
Warning

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

Go to latest
Published: May 5, 2018 License: AGPL-3.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest      = &EventError{Status: 400, Message: "The request was invalid or cannot be otherwise served."}
	ErrUnauthorized    = &EventError{Status: 401, Message: "The security key provided is not authorized to perform this operation."}
	ErrPaymentRequired = &EventError{Status: 402, Message: "The request can not be served, as the payment is required to proceed."}
	ErrForbidden       = &EventError{Status: 403, Message: "The request is understood, but it has been refused or access is not allowed."}
	ErrNotFound        = &EventError{Status: 404, Message: "The resource requested does not exist."}
	ErrServerError     = &EventError{Status: 500, Message: "An unexpected condition was encountered and no more specific message is suitable."}
	ErrNotImplemented  = &EventError{Status: 501, Message: "The server either does not recognize the request method, or it lacks the ability to fulfill the request."}
	ErrTargetInvalid   = &EventError{Status: 400, Message: "Channel should end with `/` for strict types or `/#/` for wildcards."}
	ErrTargetTooLong   = &EventError{Status: 400, Message: "Channel can not have more than 23 parts."}
)

Represents a set of errors used in the handlers.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Conn represents an incoming connection.

func (*Conn) Close

func (c *Conn) Close() error

Close terminates the connection.

func (*Conn) ID

func (c *Conn) ID() string

ID returns the unique identifier of the subsriber.

func (*Conn) Process

func (c *Conn) Process() error

Process processes the messages.

func (*Conn) Send

func (c *Conn) Send(m *message.Message) (err error)

Send forwards the message to the underlying client.

func (*Conn) Subscribe

func (c *Conn) Subscribe(ssid message.Ssid, channel []byte)

Subscribe subscribes to a particular channel.

func (*Conn) Type

func (c *Conn) Type() message.SubscriberType

Type returns the type of the subscriber

func (*Conn) Unsubscribe

func (c *Conn) Unsubscribe(ssid message.Ssid, channel []byte)

Unsubscribe unsubscribes this client from a particular channel.

type EventError

type EventError struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

EventError represents an event code which provides a more de.

func (*EventError) Error

func (e *EventError) Error() string

Error implements error interface.

type QueryHandler

type QueryHandler func(queryType string, request []byte) (response []byte, ok bool)

QueryHandler represents a query handler.

type QueryManager

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

QueryManager represents a request-response manager.

func (*QueryManager) HandleFunc

func (c *QueryManager) HandleFunc(handler QueryHandler)

HandleFunc adds a handler for a query.

func (*QueryManager) ID

func (c *QueryManager) ID() string

ID returns the unique identifier of the subsriber.

func (*QueryManager) Query

func (c *QueryManager) Query(query string, payload []byte) (message.Awaiter, error)

Query issues a cluster-wide request.

func (*QueryManager) Send

func (c *QueryManager) Send(m *message.Message) error

Send occurs when we have received a message.

func (*QueryManager) Start

func (c *QueryManager) Start()

Start subscribes the manager to the query channel.

func (*QueryManager) Type

Type returns the type of the subscriber

type Service

type Service struct {
	Closing chan bool         // The channel for closing signal.
	Cipher  *security.Cipher  // The cipher to use for decoding and encoding keys.
	License *security.License // The licence for this emitter server.
	Config  *config.Config    // The configuration for the service.
	// contains filtered or unexported fields
}

Service represents the main structure.

func NewService

func NewService(cfg *config.Config) (s *Service, err error)

NewService creates a new service.

func (*Service) Close

func (s *Service) Close()

Close closes gracefully the service.,

func (*Service) Join

func (s *Service) Join(peers ...string) []error

Join attempts to join a set of existing peers.

func (*Service) Listen

func (s *Service) Listen() (err error)

Listen starts the service.

func (*Service) LocalName

func (s *Service) LocalName() uint64

LocalName returns the local node name.

func (*Service) NumPeers

func (s *Service) NumPeers() int

NumPeers returns the number of peers of this service.

func (*Service) Query

func (s *Service) Query(query string, payload []byte) (message.Awaiter, error)

Query sends out a query to all the peers.

type StatusInfo

type StatusInfo struct {
	Node          string    `json:"node"`
	Addr          string    `json:"addr"`
	Subscriptions int       `json:"subs"`
	Connections   int64     `json:"conns"`
	CPU           float64   `json:"cpu"`
	MemoryPrivate int64     `json:"priv"`
	MemoryVirtual int64     `json:"virt"`
	Time          time.Time `json:"time"`
	NumPeers      int       `json:"peers"`
	Uptime        float64   `json:"uptime"`
}

StatusInfo represents the status payload.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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