Documentation
¶
Overview ¶
Package clustersync propagates admin configuration changes between gateway instances that share one database.
Admin-managed configuration is durable in the database but served from in-memory snapshots on each instance. Every successful admin write bumps a per-entity revision in the config_revisions table; every instance polls that tiny table and refreshes the snapshot of each entity whose revision moved. It needs nothing but the shared database, so it works the same on SQLite, PostgreSQL, and MongoDB.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MongoDBStore ¶
type MongoDBStore struct {
// contains filtered or unexported fields
}
MongoDBStore keeps configuration revisions in MongoDB.
func NewMongoDBStore ¶
func NewMongoDBStore(database *mongo.Database) (*MongoDBStore, error)
NewMongoDBStore uses the shared config_revisions collection.
type SQLStore ¶
type SQLStore struct {
// contains filtered or unexported fields
}
SQLStore keeps configuration revisions in SQLite or PostgreSQL.
func NewSQLStore ¶
NewSQLStore initializes the shared config_revisions table.
type Store ¶
type Store interface {
// Bump atomically increments the revision of entity, creating it at 1.
Bump(ctx context.Context, entity string) error
// Revisions returns the current revision of every entity bumped so far.
Revisions(ctx context.Context) (map[string]int64, error)
}
Store persists one revision counter per entity in the shared database.
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer polls the revision table and refreshes changed entities.
func New ¶
New opens the revision store on the shared storage connection. Call it before the services it refreshes load their snapshots: see NewSyncer.
func NewSyncer ¶
NewSyncer records the current revisions as already applied. Taking them before the services load means a change made while they load is refreshed on the first tick, and nothing is refreshed needlessly at startup.
func (*Syncer) Notifier ¶
Notifier returns the function a service calls after each successful admin write of entity. A failed announcement is logged and retried on every tick until one succeeds, not returned: the write itself succeeded and this instance already serves it.