discovery

package
v0.0.0-...-d0e3dbc Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2024 License: LGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IncrementalOperationChange = "change"
	IncrementalOperationRemove = "remove"
)
View Source
const (
	PeerStateInit = iota + 1
	PeerStateFull
	PeerStateExpired
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AreaSetItem

type AreaSetItem struct {
	Area string `json:"area"`

	Records []*Record `json:"records"`
}

type BatchRecordFinalizer

type BatchRecordFinalizer func(recordKeys []*RecordKey) error

type ControlData

type ControlData struct {
	Operation string // apply/recover

	MergeOperation string // change/remove
	Record                // service, area, node_id are required as primary key
}

type CustomInfo

type CustomInfo struct {
	Version int64 // used for determining update

	Data []byte
}

type DataStore

type DataStore struct {
	LocalData  localData
	PeerData   peerData
	MergedData mergedData

	sync.RWMutex
}

func NewDataStore

func NewDataStore() *DataStore

func (*DataStore) CleanupPeer

func (d *DataStore) CleanupPeer(peerId int16) error

func (*DataStore) Fetch

func (d *DataStore) Fetch(service, area string) ([]*Record, error)

func (*DataStore) InitPeer

func (d *DataStore) InitPeer(peerId int16, fullSet *FullSet) error

func (*DataStore) OfflineNRecords

func (d *DataStore) OfflineNRecords(keys []*RecordKey)

func (*DataStore) OfflineRecord

func (d *DataStore) OfflineRecord(key *RecordKey)

func (*DataStore) PeerFetchLocalFull

func (d *DataStore) PeerFetchLocalFull() (*FullSet, error)

func (*DataStore) PeerFetchLocalIncremental

func (d *DataStore) PeerFetchLocalIncremental(lastVersion int64) (*IncrementalSet, error)

func (*DataStore) PersistRecord

func (d *DataStore) PersistRecord(recordKey *RecordKey, record *Record)

func (*DataStore) UpdatePeer

func (d *DataStore) UpdatePeer(peerId int16, incSet *IncrementalSet) error

type EdgePeerService

type EdgePeerService interface {
	PeerService
}

EdgePeerService peer service across multi-level and multi-area

type ExternalDnsServer

type ExternalDnsServer struct {
}

type ExternalHttpService

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

func NewHttpService

func NewHttpService(ds *DataStore) (*ExternalHttpService, error)

func (*ExternalHttpService) StartService

func (e *ExternalHttpService) StartService() error

type FullSet

type FullSet struct {
	CurrentVersion string `json:"current_version"`

	RecordSet []*ServiceSetItem `json:"record_set"`
	// contains filtered or unexported fields
}

func (*FullSet) MarshalCbor

func (f *FullSet) MarshalCbor() ([]byte, error)

func (*FullSet) MarshalJson

func (f *FullSet) MarshalJson() ([]byte, error)

func (*FullSet) TotalRecordCount

func (f *FullSet) TotalRecordCount() int

func (*FullSet) UnmarshalCbor

func (f *FullSet) UnmarshalCbor(data []byte) error

type HttpServerPeerService

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

func (*HttpServerPeerService) FullFetch

func (h *HttpServerPeerService) FullFetch() (*FullSet, error)

func (*HttpServerPeerService) IncrementalFetch

func (h *HttpServerPeerService) IncrementalFetch(lastVersion string) (*IncrementalSet, error)

type IncrementalRecord

type IncrementalRecord struct {
	Record    Record    `json:"record"`
	RecordKey RecordKey `json:"record_key"`
	Operation string    `json:"operation"` // change/remove
}

type IncrementalSet

type IncrementalSet struct {
	CurrentVersion string `json:"current_version"`
	ReSync         bool   `json:"re_sync"`

	Records []*IncrementalRecord `json:"records"`
}

type LocalNodeService

type LocalNodeService struct {
	DataStore *DataStore
}

func (*LocalNodeService) ControlData

func (l *LocalNodeService) ControlData(data *ControlData) error

func (*LocalNodeService) CustomInformation

func (l *LocalNodeService) CustomInformation(info *CustomInfo) error

func (*LocalNodeService) Fetch

func (l *LocalNodeService) Fetch(service, area string) ([]*Record, error)

func (*LocalNodeService) Offline

func (l *LocalNodeService) Offline(key *RecordKey) error

func (*LocalNodeService) OfflineN

func (l *LocalNodeService) OfflineN(keys []*RecordKey) error

func (*LocalNodeService) SelfKeepAlive

func (l *LocalNodeService) SelfKeepAlive(recordKey *RecordKey, record *Record) error

func (*LocalNodeService) SlimKeepAlive

func (l *LocalNodeService) SlimKeepAlive(key *RecordKey) error

type LocalPeerService

type LocalPeerService struct {
	DataStore *DataStore
}

func (*LocalPeerService) FullFetch

func (l *LocalPeerService) FullFetch() (*FullSet, error)

func (*LocalPeerService) IncrementalFetch

func (l *LocalPeerService) IncrementalFetch(lastVersion string) (*IncrementalSet, error)

type Node

type Node struct {
}

type NodeService

type NodeService interface {
	SelfKeepAlive(recordKey *RecordKey, record *Record) error
	SlimKeepAlive(key *RecordKey) error
	Offline(key *RecordKey) error
	OfflineN(keys []*RecordKey) error
	ControlData(data *ControlData) error //TODO WIP

	CustomInformation(info *CustomInfo) error //TODO WIP

	// Fetch will fetch the service list by service and area.
	// Area supports nested environment which means area checks from warehouseapi.DiscoverUse will be performed.
	Fetch(service, area string) ([]*Record, error)
}

NodeService node service for processing node request

func NewLocalNodeService

func NewLocalNodeService(dataStore *DataStore) NodeService

type NodeStatusManager

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

func NewNodeStatusManager

func NewNodeStatusManager() *NodeStatusManager

func (*NodeStatusManager) KeepAlive

func (n *NodeStatusManager) KeepAlive(recordKey *RecordKey) error

func (*NodeStatusManager) Offline

func (n *NodeStatusManager) Offline(recordKey *RecordKey) error

func (*NodeStatusManager) SetBatchFinalizer

func (n *NodeStatusManager) SetBatchFinalizer(f BatchRecordFinalizer)

func (*NodeStatusManager) StartNode

func (n *NodeStatusManager) StartNode(recordKey *RecordKey) error

type Peer

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

func StartPeer

func StartPeer(peerWrapper PeerService, peerId int16, stor *DataStore) (*Peer, error)

func (*Peer) ScheduleLoop

func (p *Peer) ScheduleLoop()

type PeerService

type PeerService interface {
	FullFetch() (*FullSet, error)
	IncrementalFetch(lastVersion string) (*IncrementalSet, error)
}

PeerService peer service in the same area

func NewHttpServerPeerService

func NewHttpServerPeerService(address string, peerId int16) PeerService

func NewLocalPeerService

func NewLocalPeerService(dataStore *DataStore) PeerService

type PeerState

type PeerState int

type Record

type Record struct {
	NodeId string `json:"node_id"`

	RecordVersion int64 `json:"record_version"`

	Tags        []string `json:"tags"`
	ServiceData []byte   `json:"service_data"`
	MetaData    []byte   `json:"meta_data"`
}

type RecordKey

type RecordKey struct {
	Service string `json:"service"`
	Area    string `json:"area"`
	NodeId  string `json:"node_id"`
}

func (*RecordKey) GetKey

func (r *RecordKey) GetKey() string

type RemoteClientPeerService

type RemoteClientPeerService struct {
}

type ServiceInfo

type ServiceInfo struct {
	// Host 4b+2b/ipv4, 16b+2b/ipv6
	HostAndPort     []byte `json:"host_and_port"`
	IPv6HostAndPort []byte `json:"ipv6_host_and_port"`
}

func (*ServiceInfo) Bind

func (s *ServiceInfo) Bind(r *http.Request) error

type ServiceSetItem

type ServiceSetItem struct {
	Service string `json:"service"`

	Areas []*AreaSetItem `json:"areas"`
}

type TimeoutEntry

type TimeoutEntry struct {
	*RecordKey
	ExpireTime time.Time
	Deleted    bool
}

Jump to

Keyboard shortcuts

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