connection

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2017 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BootstrapService

func BootstrapService(manager *Manager, socket *websocket.Conn)

BootstrapService creates a new Service which will alert the manager when the service registers (by sending its first message) and deregisters (by disconnecting)

Types

type Client

type Client struct {
	Role      string `json:"role"`
	Instances int    `json:"instances"`
}

Client represents a service connected to exocom

type Manager

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

Manager manages all websocket connections

func NewManager

func NewManager(options ManagerOptions) *Manager

NewManager returns a new Manager

func (*Manager) AddWebsocket

func (m *Manager) AddWebsocket(socket *websocket.Conn)

AddWebsocket adds the websocket under the manager's control

func (*Manager) GetClients

func (m *Manager) GetClients() (result []Client)

GetClients returns all the connections

func (*Manager) SendMessage

func (m *Manager) SendMessage(role string, message structs.Message) error

SendMessage sends the given message to the service with the given role

type ManagerOptions added in v0.25.0

type ManagerOptions struct {
	DeregisterChannel         chan string
	ErrorChannel              chan error
	MessageChannel            chan structs.Message
	RegisterChannel           chan string
	ActivityIDCleanupInterval time.Duration
}

ManagerOptions is the options passed to NewManager

type NestedServiceMapping added in v0.26.2

type NestedServiceMapping map[string]map[string]*Service

NestedServiceMapping is a 2 level map of strings to Services

func (NestedServiceMapping) Delete added in v0.26.2

func (n NestedServiceMapping) Delete(key1, key2 string)

Delete retrives the value for the given keys

func (NestedServiceMapping) DeleteForService added in v0.26.2

func (n NestedServiceMapping) DeleteForService(key1 string, service *Service)

DeleteForService deletes all the keys under the given key that are the given service

func (NestedServiceMapping) DeleteNestedKey added in v0.26.3

func (n NestedServiceMapping) DeleteNestedKey(nestedKey string)

DeleteNestedKey deletes entries for a nested key

func (NestedServiceMapping) Get added in v0.26.2

func (n NestedServiceMapping) Get(key1, key2 string) *Service

Get retrives the value for the given keys

func (NestedServiceMapping) GetRandom added in v0.26.2

func (n NestedServiceMapping) GetRandom(key1 string) *Service

GetRandom retrives a random Service under the given key

func (NestedServiceMapping) Set added in v0.26.2

func (n NestedServiceMapping) Set(key1, key2 string, value *Service)

Set saves the value for the given keys

type Service

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

Service manages a single websocket connection

func (*Service) Send

func (s *Service) Send(message structs.Message) error

Send sends the given message on the websocket

Jump to

Keyboard shortcuts

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