cluster

package
v0.0.0-...-b47d8ff Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackoffMinInterval = 1 * time.Second
	BackoffMaxInterval = 60 * time.Second
	BackoffMultiplier  = 1.5
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cluster

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

func NewCluster

func NewCluster(conf *ClusterCfg) *Cluster

func (*Cluster) Run

func (m *Cluster) Run(ctx context.Context, stopNotifyCh chan<- struct{})

func (*Cluster) ServeHTTP

func (m *Cluster) ServeHTTP(w http.ResponseWriter, r *http.Request)

type ClusterCfg

type ClusterCfg struct {
	Pid  int
	Addr string
	Hub  IHub
	Mux  *http.ServeMux

	RunLeader   bool
	RunFollower bool
	LeaderAddr  string

	KafkaBrokers []string
	KafkaTopic   string
	KafkaGroupId string

	EnableClientMsg bool

	EventManager         store.IEventStore
	CleanEvents          bool
	EventTTLDays         int32
	EventPayloadMaxBytes int32

	SessionQuota int32
}

type ICluster

type ICluster interface {
	Run(ctx context.Context, stopNotifyCh chan<- struct{})
	SaveMsg(ctx context.Context, msg *pb.E2EMsg) error
}

type IHub

type IHub interface {
	Run(context.Context, chan<- *pb.FollowerMsg, <-chan *pb.LeaderMsg, chan<- struct{})
	Kickoff(string)
	Online()
	Offline()
}

IHub provides interfaces of local Hub.

type IKafkaReader

type IKafkaReader interface {
	FetchMessage(context.Context) (kafka.Message, error)
	CommitMessages(context.Context, ...kafka.Message) error
	Close() error
}

type IKafkaWriter

type IKafkaWriter interface {
	WriteMessages(context.Context, ...kafka.Message) error
	Close() error
}

type KafkaMsgValue

type KafkaMsgValue struct {
	Body   string  `json:"body,omitempty"` // event body in JSON format
	ToUids []int32 `json:"uids,omitempty"`
}

kafka message value.

type SessionStore

type SessionStore struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

memory cluster session store.

type Standalone

type Standalone struct {
	ICluster
	sync.RWMutex
	// contains filtered or unexported fields
}

Standalone is a standalone server, with out running leader and follower. It is equivalent to one node cluster with gRPC client and server

func NewStandalone

func NewStandalone(conf *ClusterCfg) *Standalone

func (*Standalone) Run

func (s *Standalone) Run(ctx context.Context, stopNotifyCh chan<- struct{})

Directories

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳