server

package
v0.0.0-...-ac41614 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2022 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	INCOMING = iota
	OUTGOING = iota
)
View Source
const (
	START              = iota
	HANDSHAKE          = iota
	ROOT_HASH_COMPARE  = iota
	LEFT_HASH_COMPARE  = iota
	RIGHT_HASH_COMPARE = iota
	HASH_COMPARE       = iota
	DB_OBJECT_PUSH     = iota
	END                = iota
)
View Source
const (
	SYNC_START        = iota
	SYNC_ABORT        = iota
	SYNC_NODE_HASH    = iota
	SYNC_OBJECT_NEXT  = iota
	SYNC_PUSH_MESSAGE = iota
	REQUEST           = iota
	RESPONSE          = iota
	PUSH              = iota
	SYNC_PUSH_DONE    = iota
)
View Source
const CLOUD_PEER_ID = "cloud"
View Source
const PING_PERIOD_SECONDS = 40
View Source
const PONG_WAIT_SECONDS = 60
View Source
const PROTOCOL_VERSION uint = 2
View Source
const RECONNECT_WAIT_MAX_SECONDS = 32
View Source
const SYNC_SESSION_WAIT_TIMEOUT_SECONDS = 5
View Source
const WRITE_WAIT_SECONDS = 10

Variables

This section is empty.

Functions

func MakeeventsFromEvents

func MakeeventsFromEvents(es []*historian.Event) []*event

func MessageTypeName

func MessageTypeName(m int) string

func StateName

func StateName(s int) string

Types

type Abort

type Abort struct {
}

type AlertEventData

type AlertEventData struct {
	Metadata interface{} `json:"metadata"`
	Status   bool        `json:"status"`
}

type CloudServer

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

func NewCloudServer

func NewCloudServer(serverConfig CloudServerConfig) *CloudServer

func (*CloudServer) ExternalHost

func (server *CloudServer) ExternalHost() string

func (*CloudServer) ExternalPort

func (server *CloudServer) ExternalPort() int

func (*CloudServer) InternalHost

func (server *CloudServer) InternalHost() string

func (*CloudServer) InternalPort

func (server *CloudServer) InternalPort() int

func (*CloudServer) IsHTTPOnly

func (server *CloudServer) IsHTTPOnly() bool

func (*CloudServer) Router

func (server *CloudServer) Router() *mux.Router

func (*CloudServer) Start

func (server *CloudServer) Start() error

func (*CloudServer) Stop

func (server *CloudServer) Stop()

type CloudServerConfig

type CloudServerConfig struct {
	NodeID         uint64
	ExternalPort   int
	ExternalHost   string
	InternalPort   int
	InternalHost   string
	RelayTLSConfig *tls.Config
}

type Hub

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

func NewHub

func NewHub(id string, syncController *SyncController, tlsConfig *tls.Config) *Hub

func (*Hub) Accept

func (hub *Hub) Accept(connection *websocket.Conn, partitionNumber uint64, relayID string, siteID string, noValidate bool) error

func (*Hub) BroadcastUpdate

func (hub *Hub) BroadcastUpdate(siteID string, bucket string, update map[string]*SiblingSet, n uint64)

func (*Hub) Connect

func (hub *Hub) Connect(peerID, host string, port int) error

func (*Hub) ConnectCloud

func (hub *Hub) ConnectCloud(serverName, uri, historyServerName, historyURI, alertsServerName, alertsURI string, noValidate bool) error

func (*Hub) Disconnect

func (hub *Hub) Disconnect(peerID string)

func (*Hub) ExtractPeerID

func (hub *Hub) ExtractPeerID(conn *tls.Conn) (string, error)

func (*Hub) ForwardAlerts

func (hub *Hub) ForwardAlerts()

func (*Hub) ForwardEvents

func (hub *Hub) ForwardEvents()

func (*Hub) PeerStatus

func (hub *Hub) PeerStatus(peerID string) (connected bool, pingTime time.Duration)

func (*Hub) Peers

func (hub *Hub) Peers() []*PeerJSON

func (*Hub) ReconnectPeer

func (hub *Hub) ReconnectPeer(peerID string)

func (*Hub) ReconnectPeerByPartition

func (hub *Hub) ReconnectPeerByPartition(partitionNumber uint64)

func (*Hub) ReconnectPeerBySite

func (hub *Hub) ReconnectPeerBySite(siteID string)

func (*Hub) StartForwardingAlerts

func (hub *Hub) StartForwardingAlerts()

func (*Hub) StartForwardingEvents

func (hub *Hub) StartForwardingEvents()

func (*Hub) SyncController

func (hub *Hub) SyncController() *SyncController

type InitiatorSyncSession

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

the state machine

func NewInitiatorSyncSession

func NewInitiatorSyncSession(id uint, bucketProxy ddbSync.BucketProxy, explorationPathLimit uint32, replicatesOutgoing bool) *InitiatorSyncSession

func (*InitiatorSyncSession) ExplorationPathLimit

func (syncSession *InitiatorSyncSession) ExplorationPathLimit() uint32

func (*InitiatorSyncSession) ExplorationQueueSize

func (syncSession *InitiatorSyncSession) ExplorationQueueSize() uint32

func (*InitiatorSyncSession) NextState

func (syncSession *InitiatorSyncSession) NextState(syncMessageWrapper *SyncMessageWrapper) *SyncMessageWrapper

func (*InitiatorSyncSession) PeekExplorationQueue

func (syncSession *InitiatorSyncSession) PeekExplorationQueue() uint32

func (*InitiatorSyncSession) PopExplorationQueue

func (syncSession *InitiatorSyncSession) PopExplorationQueue() uint32

func (*InitiatorSyncSession) PushExplorationQueue

func (syncSession *InitiatorSyncSession) PushExplorationQueue(n uint32)

func (*InitiatorSyncSession) ResponderDepth

func (syncSession *InitiatorSyncSession) ResponderDepth() uint8

func (*InitiatorSyncSession) SetExplorationPathLimit

func (syncSession *InitiatorSyncSession) SetExplorationPathLimit(limit uint32)

func (*InitiatorSyncSession) SetResponderDepth

func (syncSession *InitiatorSyncSession) SetResponderDepth(d uint8)

func (*InitiatorSyncSession) SetState

func (syncSession *InitiatorSyncSession) SetState(state int)

func (*InitiatorSyncSession) State

func (syncSession *InitiatorSyncSession) State() int

type MerkleNodeHash

type MerkleNodeHash struct {
	NodeID   uint32
	HashHigh uint64
	HashLow  uint64
}

type ObjectNext

type ObjectNext struct {
	NodeID uint32
}

type Peer

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

func NewPeer

func NewPeer(id string, direction int) *Peer

type PeerJSON

type PeerJSON struct {
	Direction string `json:"direction"`
	ID        string `json:"id"`
	Status    string `json:"status"`
}

type PushDone

type PushDone struct {
}

type PushMessage

type PushMessage struct {
	Bucket string
	Key    string
	Value  *SiblingSet
}

type ResponderSyncSession

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

the state machine

func NewResponderSyncSession

func NewResponderSyncSession(bucketProxy ddbSync.BucketProxy) *ResponderSyncSession

func (*ResponderSyncSession) InitiatorDepth

func (syncSession *ResponderSyncSession) InitiatorDepth() uint8

func (*ResponderSyncSession) NextState

func (syncSession *ResponderSyncSession) NextState(syncMessageWrapper *SyncMessageWrapper) *SyncMessageWrapper

func (*ResponderSyncSession) SetInitiatorDepth

func (syncSession *ResponderSyncSession) SetInitiatorDepth(d uint8)

func (*ResponderSyncSession) SetState

func (syncSession *ResponderSyncSession) SetState(state int)

func (*ResponderSyncSession) State

func (syncSession *ResponderSyncSession) State() int

type Server

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

func NewServer

func NewServer(serverConfig ServerConfig) (*Server, error)

func (*Server) AlertsMap

func (server *Server) AlertsMap() *AlertMap

func (*Server) Buckets

func (server *Server) Buckets() *BucketList

func (*Server) History

func (server *Server) History() *Historian

func (*Server) Port

func (server *Server) Port() int

func (*Server) Start

func (server *Server) Start() error

func (*Server) StartGC

func (server *Server) StartGC()

func (*Server) Stop

func (server *Server) Stop() error

func (*Server) StopGC

func (server *Server) StopGC()

type ServerConfig

type ServerConfig struct {
	DBFile                   string
	Port                     int
	MerkleDepth              uint8
	NodeID                   string
	Hub                      *Hub
	ServerTLS                *tls.Config
	PeerAddresses            map[string]peerAddress
	SyncPushBroadcastLimit   uint64
	GCInterval               uint64
	GCPurgeAge               uint64
	Cloud                    *cloudAddress
	History                  *cloudAddress
	Alerts                   *cloudAddress
	HistoryPurgeOnForward    bool
	HistoryEventLimit        uint64
	HistoryEventFloor        uint64
	HistoryPurgeBatchSize    int
	HistoryForwardBatchSize  uint64
	HistoryForwardInterval   uint64
	HistoryForwardThreshold  uint64
	AlertsForwardInterval    uint64
	SyncExplorationPathLimit uint32
}

func (*ServerConfig) LoadFromFile

func (sc *ServerConfig) LoadFromFile(file string) error

type Start

type Start struct {
	ProtocolVersion uint
	MerkleDepth     uint8
	Bucket          string
}

type SyncController

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

func NewSyncController

func NewSyncController(maxSyncSessions uint, bucketProxyFactory ddbSync.BucketProxyFactory, syncScheduler ddbSync.SyncScheduler, explorationPathLimit uint32) *SyncController

func (*SyncController) BroadcastUpdate

func (s *SyncController) BroadcastUpdate(peerID string, bucket string, update map[string]*SiblingSet, n uint64)

func (*SyncController) Start

func (s *SyncController) Start()

func (*SyncController) StartInitiatorSessions

func (s *SyncController) StartInitiatorSessions()

func (*SyncController) StartResponderSessions

func (s *SyncController) StartResponderSessions()

type SyncMessageWrapper

type SyncMessageWrapper struct {
	SessionID   uint        `json:"sessionID"`
	MessageType int         `json:"type"`
	MessageBody interface{} `json:"body"`
	Direction   uint        `json:"dir"`
	// contains filtered or unexported fields
}

type SyncSession

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

Jump to

Keyboard shortcuts

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