cluster

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2019 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetBindBroadcastTopic

func GetBindBroadcastTopic(svType string) string

GetBindBroadcastTopic gets the topic on which bind events will be broadcasted

func GetUserKickTopic added in v0.7.6

func GetUserKickTopic(uid string, svType string) string

GetUserKickTopic get the topic for kicking an user

func GetUserMessagesTopic

func GetUserMessagesTopic(uid string, svType string) string

GetUserMessagesTopic get the topic for user

Types

type Action

type Action int

Action type for enum

const (
	ADD Action = iota
	DEL
)

Action values

type ConfigInfoRetriever added in v0.7.6

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

ConfigInfoRetriever gets cluster info from config Implements InfoRetriever interface

func NewConfigInfoRetriever added in v0.7.6

func NewConfigInfoRetriever(c *config.Config) *ConfigInfoRetriever

NewConfigInfoRetriever returns a *ConfigInfoRetriever

func (*ConfigInfoRetriever) Region added in v0.7.6

func (c *ConfigInfoRetriever) Region() string

Region gets server's region from config

type GRPCClient

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

GRPCClient rpc server struct

func NewGRPCClient

func NewGRPCClient(
	config *config.Config,
	server *Server,
	metricsReporters []metrics.Reporter,
	bindingStorage interfaces.BindingStorage,
	infoRetriever InfoRetriever,
) (*GRPCClient, error)

NewGRPCClient returns a new instance of GRPCClient

func (*GRPCClient) AddServer

func (gs *GRPCClient) AddServer(sv *Server)

AddServer is called when a new server is discovered

func (*GRPCClient) AfterInit

func (gs *GRPCClient) AfterInit()

AfterInit runs after initialization

func (*GRPCClient) BeforeShutdown

func (gs *GRPCClient) BeforeShutdown()

BeforeShutdown runs before shutdown

func (*GRPCClient) BroadcastSessionBind

func (gs *GRPCClient) BroadcastSessionBind(uid string) error

BroadcastSessionBind sends the binding information to other servers that may be interested in this info

func (*GRPCClient) Call

func (gs *GRPCClient) Call(ctx context.Context, rpcType protos.RPCType, route *route.Route, session *session.Session, msg *message.Message, server *Server) (*protos.Response, error)

Call makes a RPC Call

func (*GRPCClient) Init

func (gs *GRPCClient) Init() error

Init inits grpc rpc client

func (*GRPCClient) RemoveServer

func (gs *GRPCClient) RemoveServer(sv *Server)

RemoveServer is called when a server is removed

func (*GRPCClient) Send

func (gs *GRPCClient) Send(uid string, d []byte) error

Send not implemented in grpc client

func (*GRPCClient) SendKick added in v0.7.6

func (gs *GRPCClient) SendKick(userID string, serverType string, kick *protos.KickMsg) error

SendKick sends a kick to an user

func (*GRPCClient) SendPush

func (gs *GRPCClient) SendPush(userID string, frontendSv *Server, push *protos.Push) error

SendPush sends a message to an user, if you dont know the serverID that the user is connected to, you need to set a BindingStorage when creating the client TODO: Jaeger?

func (*GRPCClient) Shutdown

func (gs *GRPCClient) Shutdown() error

Shutdown stops grpc rpc server

type GRPCServer

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

GRPCServer rpc server struct

func NewGRPCServer

func NewGRPCServer(config *config.Config, server *Server, metricsReporters []metrics.Reporter) (*GRPCServer, error)

NewGRPCServer constructor

func (*GRPCServer) AfterInit

func (gs *GRPCServer) AfterInit()

AfterInit runs after initialization

func (*GRPCServer) BeforeShutdown

func (gs *GRPCServer) BeforeShutdown()

BeforeShutdown runs before shutdown

func (*GRPCServer) Init

func (gs *GRPCServer) Init() error

Init inits grpc rpc server

func (*GRPCServer) SetPitayaServer

func (gs *GRPCServer) SetPitayaServer(ps protos.PitayaServer)

SetPitayaServer sets the pitaya server

func (*GRPCServer) Shutdown

func (gs *GRPCServer) Shutdown() error

Shutdown stops grpc rpc server

type InfoRetriever added in v0.7.6

type InfoRetriever interface {
	Region() string
}

InfoRetriever gets cluster info It can be implemented, for exemple, by reading env var, config or by accessing the cluster API

type NatsRPCClient

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

NatsRPCClient struct

func NewNatsRPCClient

func NewNatsRPCClient(
	config *config.Config,
	server *Server,
	metricsReporters []metrics.Reporter,
	appDieChan chan bool,
) (*NatsRPCClient, error)

NewNatsRPCClient ctor

func (*NatsRPCClient) AfterInit

func (ns *NatsRPCClient) AfterInit()

AfterInit runs after initialization

func (*NatsRPCClient) BeforeShutdown

func (ns *NatsRPCClient) BeforeShutdown()

BeforeShutdown runs before shutdown

func (*NatsRPCClient) BroadcastSessionBind

func (ns *NatsRPCClient) BroadcastSessionBind(uid string) error

BroadcastSessionBind sends the binding information to other servers that may br interested in this info

func (*NatsRPCClient) Call

func (ns *NatsRPCClient) Call(
	ctx context.Context,
	rpcType protos.RPCType,
	route *route.Route,
	session *session.Session,
	msg *message.Message,
	server *Server,
) (*protos.Response, error)

Call calls a method remotelly

func (*NatsRPCClient) Init

func (ns *NatsRPCClient) Init() error

Init inits nats rpc client

func (*NatsRPCClient) Send

func (ns *NatsRPCClient) Send(topic string, data []byte) error

Send publishes a message in a given topic

func (*NatsRPCClient) SendKick added in v0.7.6

func (ns *NatsRPCClient) SendKick(userID string, serverType string, kick *protos.KickMsg) error

SendKick kicks an user

func (*NatsRPCClient) SendPush

func (ns *NatsRPCClient) SendPush(userID string, frontendSv *Server, push *protos.Push) error

SendPush sends a message to a user

func (*NatsRPCClient) Shutdown

func (ns *NatsRPCClient) Shutdown() error

Shutdown stops nats rpc server

type NatsRPCServer

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

NatsRPCServer struct

func NewNatsRPCServer

func NewNatsRPCServer(
	config *config.Config,
	server *Server,
	metricsReporters []metrics.Reporter,
	appDieChan chan bool,
) (*NatsRPCServer, error)

NewNatsRPCServer ctor

func (*NatsRPCServer) AfterInit

func (ns *NatsRPCServer) AfterInit()

AfterInit runs after initialization

func (*NatsRPCServer) BeforeShutdown

func (ns *NatsRPCServer) BeforeShutdown()

BeforeShutdown runs before shutdown

func (*NatsRPCServer) GetBindingsChannel

func (ns *NatsRPCServer) GetBindingsChannel() chan *nats.Msg

GetBindingsChannel gets the channel that will receive all bindings

func (*NatsRPCServer) GetUnhandledRequestsChannel

func (ns *NatsRPCServer) GetUnhandledRequestsChannel() chan *protos.Request

GetUnhandledRequestsChannel gets the unhandled requests channel from nats rpc server

func (*NatsRPCServer) Init

func (ns *NatsRPCServer) Init() error

Init inits nats rpc server

func (*NatsRPCServer) SetPitayaServer

func (ns *NatsRPCServer) SetPitayaServer(ps protos.PitayaServer)

SetPitayaServer sets the pitaya server

func (*NatsRPCServer) Shutdown

func (ns *NatsRPCServer) Shutdown() error

Shutdown stops nats rpc server

type RPCClient

type RPCClient interface {
	Send(route string, data []byte) error
	SendPush(userID string, frontendSv *Server, push *protos.Push) error
	SendKick(userID string, serverType string, kick *protos.KickMsg) error
	BroadcastSessionBind(uid string) error
	Call(ctx context.Context, rpcType protos.RPCType, route *route.Route, session *session.Session, msg *message.Message, server *Server) (*protos.Response, error)
	interfaces.Module
}

RPCClient interface

type RPCServer

type RPCServer interface {
	SetPitayaServer(protos.PitayaServer)
	interfaces.Module
}

RPCServer interface

type RemoteBindingListener

type RemoteBindingListener interface {
	OnUserBind(uid, fid string)
}

RemoteBindingListener listens to session bindings in remote servers

type SDListener

type SDListener interface {
	AddServer(*Server)
	RemoveServer(*Server)
}

SDListener interface

type Server

type Server struct {
	ID       string            `json:"id"`
	Type     string            `json:"type"`
	Metadata map[string]string `json:"metadata"`
	Frontend bool              `json:"frontend"`
	Hostname string            `json:"hostname"`
}

Server struct

func NewServer

func NewServer(id, serverType string, frontend bool, metadata ...map[string]string) *Server

NewServer ctor

func (*Server) AsJSONString

func (s *Server) AsJSONString() string

AsJSONString returns the server as a json string

type ServiceDiscovery

type ServiceDiscovery interface {
	GetServersByType(serverType string) (map[string]*Server, error)
	GetServer(id string) (*Server, error)
	GetServers() []*Server
	SyncServers() error
	AddListener(listener SDListener)
	interfaces.Module
}

ServiceDiscovery is the interface for a service discovery client

func NewEtcdServiceDiscovery

func NewEtcdServiceDiscovery(
	config *config.Config,
	server *Server,
	appDieChan chan bool,
	cli ...*clientv3.Client,
) (ServiceDiscovery, error)

NewEtcdServiceDiscovery ctor

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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