mesh

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PeerAddrHeader = 11

	RaftConnectType    = 2048
	RaftDataType       = 2049
	SigningCertHeader  = 2050
	ApiAddressesHeader = 2051

	ChannelTypeMesh = "ctrl.mesh"
)

Variables

This section is empty.

Functions

func ExtractSpiffeId

func ExtractSpiffeId(certs []*x509.Certificate) (string, error)

Types

type ClusterState

type ClusterState uint32
const (
	ClusterReadWrite ClusterState = 0
	ClusterReadOnly  ClusterState = 1
)

type Env

type Env interface {
	GetId() *identity.TokenId
	GetVersionProvider() versions.VersionProvider
	GetEventDispatcher() event.Dispatcher
}

type HeaderProvider added in v0.34.2

type HeaderProvider interface {
	Apply(map[int32][]byte)
}

type HeaderProviderFunc added in v0.34.2

type HeaderProviderFunc func(map[int32][]byte)

func (HeaderProviderFunc) Apply added in v0.34.2

func (self HeaderProviderFunc) Apply(headers map[int32][]byte)

type Mesh

type Mesh interface {
	raft.StreamLayer

	channel.UnderlayAcceptor

	// GetOrConnectPeer returns a peer for the given address. If a peer has already been established,
	// it will be returned, otherwise a new connection will be established
	GetOrConnectPeer(address string, timeout time.Duration) (*Peer, error)
	IsReadOnly() bool

	GetPeerInfo(address string, timeout time.Duration) (raft.ServerID, raft.ServerAddress, error)
	GetAdvertiseAddr() raft.ServerAddress
	GetPeers() map[string]*Peer

	RegisterClusterStateHandler(f func(state ClusterState))
	Init(bindHandler channel.BindHandler)
}

Mesh provides the networking layer to raft

func New

func New(env Env, raftAddr raft.ServerAddress, helloHeaderProviders []HeaderProvider) Mesh

type Peer

type Peer struct {
	Id           raft.ServerID
	Address      string
	Channel      channel.Channel
	RaftConn     *raftPeerConn
	Version      *versions.VersionInfo
	SigningCerts []*x509.Certificate
	ApiAddresses map[string][]event.ApiAddress
	// contains filtered or unexported fields
}

func (*Peer) Connect

func (self *Peer) Connect(timeout time.Duration) error

func (*Peer) ContentType

func (self *Peer) ContentType() int32

func (*Peer) HandleClose

func (self *Peer) HandleClose(channel.Channel)

func (*Peer) HandleReceive

func (self *Peer) HandleReceive(m *channel.Message, _ channel.Channel)

Jump to

Keyboard shortcuts

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