internal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Globals struct {
	Cluster *Cluster

	Service *_Service
	// contains filtered or unexported fields
}

Functions

func ClusterInit

func ClusterInit(configString json.RawMessage, self *string) int

Returns worker id

func NewConnCache

func NewConnCache() *_ConnCache

func NewService

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

func ResponseHandler

func ResponseHandler(w http.ResponseWriter, r *http.Request, data []byte)

ResponseHandler handles responses for monitoring routes

func TimeNow

func TimeNow() time.Time

TimeNow returns current wall time in UTC rounded to milliseconds.

Types

type Cluster

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

Cluster is the representation of the cluster.

func (*Cluster) Master

func (c *Cluster) Master(reqMsg *ClusterReq, rejected *bool) error

Master at topic's master node receives C2S messages from topic's proxy nodes. The message is treated like it came from a session: find or create a session locally, dispatch the message to it like it came from a normal ws/lp connection. Called by a remote node.

func (*Cluster) Ping

func (c *Cluster) Ping(ping *ClusterPing, unused *bool) error

Ping is called by the leader node to assert leadership and check status of the followers.

func (Cluster) Proxy

func (Cluster) Proxy(resp *ClusterResp, unused *bool) error

Dispatch receives messages from the master node addressed to a specific local connection.

func (*Cluster) Start

func (c *Cluster) Start()

Start accepting connections.

func (*Cluster) Vote

func (c *Cluster) Vote(vreq *ClusterVoteRequest, response *ClusterVoteResponse) error

Vote processes request for a vote from a candidate.

type ClusterNode

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

ClusterNode is a client's connection to another node.

type ClusterPing

type ClusterPing struct {
	// Name of the leader node
	Leader string
	// Election term
	Term int
	// Ring hash signature that represents the cluster
	Signature string
	// Names of nodes currently active in the cluster
	Nodes []string
}

ClusterPing is content of a leader node ping to a follower node.

type ClusterReq

type ClusterReq struct {
	// Name of the node sending this request
	Node string

	// Ring hash signature of the node sending this request
	// Signature must match the signature of the receiver, otherwise the
	// Cluster is desynchronized.
	Signature string

	SubMsg   *utp.Subscribe
	PubMsg   *utp.Publish
	UnsubMsg *utp.Unsubscribe
	Topic    *security.Topic
	Type     uint8
	Message  *message.Message

	// Originating session
	Conn *ClusterSess
	// True if the original session has disconnected
	ConnGone bool
}

ClusterReq is a Proxy to Master request message.

type ClusterResp

type ClusterResp struct {
	Type     uint8
	SubMsg   *utp.Subscribe
	PubMsg   *utp.Publish
	UnsubMsg *utp.Unsubscribe
	RespMsg  []byte
	Topic    *security.Topic
	Message  *message.Message
	// Connection ID to forward message to, if any.
	FromConnID uid.LID
}

ClusterResp is a Master to Proxy response message.

type ClusterSess

type ClusterSess struct {
	// IP address of the client. For long polling this is the IP of the last poll
	RemoteAddr string
	// protocol - NONE (unset), RPC, GRPC, GRPC_WEB, WEBSOCK
	Proto lp.Proto
	// Connection ID
	ConnID uid.LID
	// Session ID
	SessID uid.LID
	// Client ID
	ClientID uid.ID
}

ClusterSess is a basic info on a remote session where the message was created.

type ClusterVote

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

ClusterVote is a vote request and a response in leader election.

type ClusterVoteRequest

type ClusterVoteRequest struct {
	// Candidate node which issued this request
	Node string
	// Election term
	Term int
}

ClusterVoteRequest is a request from a leader candidate to a node to vote for the candidate.

type ClusterVoteResponse

type ClusterVoteResponse struct {
	// Actual vote
	Result bool
	// Node's term after the vote
	Term int
}

ClusterVoteResponse is a vote from a node.

type Meter

type Meter struct {
	Metrics        metrics.Metrics
	ConnTimeSeries metrics.TimeSeries
	Connections    metrics.Counter
	Subscriptions  metrics.Counter
	InMsgs         metrics.Counter
	OutMsgs        metrics.Counter
	InBytes        metrics.Counter
	OutBytes       metrics.Counter
}

func NewMeter

func NewMeter() *Meter

func (*Meter) UnregisterAll

func (m *Meter) UnregisterAll()

type Varz

type Varz struct {
	Start         time.Time `json:"start"`
	Now           time.Time `json:"now"`
	Uptime        string    `json:"uptime"`
	Connections   int64     `json:"connections"`
	InMsgs        int64     `json:"in_msgs"`
	OutMsgs       int64     `json:"out_msgs"`
	InBytes       int64     `json:"in_bytes"`
	OutBytes      int64     `json:"out_bytes"`
	Subscriptions int64     `json:"subscriptions"`
	HMean         float64   `json:"hmean"` // Event duration harmonic mean.
	P50           float64   `json:"p50"`   // Event duration nth percentiles ..
	P75           float64   `json:"p75"`
	P95           float64   `json:"p95"`
	P99           float64   `json:"p99"`
	P999          float64   `json:"p999"`
	Long5p        float64   `json:"long_5p"`  // Average of the longest 5% event durations.
	Short5p       float64   `json:"short_5p"` // Average of the shortest 5% event durations.
	Max           float64   `json:"max"`      // Highest event duration.
	Min           float64   `json:"min"`      // Lowest event duration.
	StdDev        float64   `json:"stddev"`   // Standard deviation.

}

Stats will output server information on the monitoring port at /varz.

Directories

Path Synopsis
db
net
pkg
hash
Package ringhash implementats a consistent ring hash: https://en.wikipedia.org/wiki/Consistent_hashing
Package ringhash implementats a consistent ring hash: https://en.wikipedia.org/wiki/Consistent_hashing
log
stats
Package Meter yields summarized data describing a series of timed events.
Package Meter yields summarized data describing a series of timed events.
uid

Jump to

Keyboard shortcuts

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