Documentation
¶
Overview ¶
Package syncing provides a way to sync apps between peers
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrPeerNotFound = errors.New("not found")
ErrPeerNotFound is returned when a peer is not found in the metadata storage
Functions ¶
This section is empty.
Types ¶
type AppSource ¶
AppSource is an interface for listing apps
func NewAddressEnrichingAppSource ¶
NewAddressEnrichingAppSource creates a new AppSource that enriches the apps with the given hostname
func NewInMemoryAppStorage ¶
func NewInMemoryAppStorage() AppSource
NewInMemoryAppStorage creates a new in-memory AppSource instance
func NewPeerEnrichingAppSource ¶
NewPeerEnrichingAppSource creates a new AppSource that enriches the apps with the given peer
type AppStateChangeGenerator ¶
type AppStateChangeGenerator struct {
// contains filtered or unexported fields
}
AppStateChangeGenerator is a generator that listens for changes in the app state and generates events
func NewAppStateChangeGenerator ¶
func NewAppStateChangeGenerator() *AppStateChangeGenerator
NewAppStateChangeGenerator creates a new AppStateChangeGenerator
func (*AppStateChangeGenerator) Changes ¶
func (s *AppStateChangeGenerator) Changes() chan svcdetector.AppStateChange
Changes returns the channel where changes are sent
func (*AppStateChangeGenerator) UpdateForPeer ¶
func (s *AppStateChangeGenerator) UpdateForPeer(peer string, theApps []apps.App)
UpdateForPeer is called when a sync message is received
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a struct that orchestrates all the operations that are performed client-side when executing app list synchronizations
func NewClient ¶
func NewClient( myName string, nginxAdapter *AppStateChangeGenerator, encoder Encoder, interval time.Duration, apps AppSource, transport ClientTransport, MetadataFactory MetadataFactory, ) *Client
NewClient creates a new SyncingClient instance
func NewHTTPClient ¶
func NewHTTPClient( myName string, nginxAdapter *AppStateChangeGenerator, encoder Encoder, interval time.Duration, apps AppSource, pr pairing.Response, metadata MetadataFactory, ) (*Client, error)
NewHTTPClient creates a new SyncingClient instance with HTTP transport
type ClientTransport ¶
ClientTransport is an interface for syncing clients transport. Example implementations can be http, grpc, etc.
func NewHTTPClientTransport ¶
func NewHTTPClientTransport(serverURL string, timeout time.Duration) ClientTransport
NewHTTPClientTransport creates a new SyncClientTransport instance
type Encoder ¶
Encoder is an interface for encoding and decoding syncing messages
func NewJSONSyncingEncoder ¶
func NewJSONSyncingEncoder() Encoder
NewJSONSyncingEncoder creates a new SyncingEncoder instance
type IncomingSyncRequest ¶
IncomingSyncRequest is a struct that represents raw incoming sync requests
type MetadataFactory ¶
MetadataFactory is an interface for creating metadata, can be used for example for loading mounted secrets in kubernetes and reloading metadata without restarting the application
func NewStaticMetadataFactory ¶
func NewStaticMetadataFactory(metadata Metadata) MetadataFactory
NewStaticMetadataFactory creates a new static metadata factory
type MetadataListItem ¶
MetadataListItem is used to present metadata in a list
type MetadataStorage ¶
type MetadataStorage interface {
List() ([]MetadataListItem, error)
Set(peer string, metadata Metadata) error
Get(peer string) (Metadata, error)
}
MetadataStorage is an interface for storing and retrieving metadata
func NewBoltMetadataStorage ¶
func NewBoltMetadataStorage(path string) (MetadataStorage, error)
NewBoltMetadataStorage creates a new metadata storage that stores metadata in a BoltDB database
func NewCachingMetadataStorage ¶
func NewCachingMetadataStorage(storage MetadataStorage) MetadataStorage
NewCachingMetadataStorage creates a new metadata storage that caches metadata in memory
func NewInMemoryMetadataStorage ¶
func NewInMemoryMetadataStorage() MetadataStorage
NewInMemoryMetadataStorage creates a new in-memory metadata storage
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server orchestrates all the operations that are performed server-side when executing app list synchronizations
func NewServer ¶
func NewServer( myName string, stateGenerator *AppStateChangeGenerator, apps AppSource, encoder Encoder, transport ServerTransport, peers pairing.PeerStorage, metadata MetadataStorage, ) *Server
NewServer creates a new SyncingServer instance
type ServerTransport ¶
type ServerTransport interface {
Syncs() <-chan IncomingSyncRequest
Metadata() map[string]string
}
ServerTransport is an interface for syncing servers transport, similar to SyncClientTransport
func NewHTTPServerSyncingTransport ¶
func NewHTTPServerSyncingTransport(server *http.Server) ServerTransport
NewHTTPServerSyncingTransport creates a new SyncServerTransport instance