Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LayeredRegistry ¶ added in v0.0.4
type LayeredRegistry struct {
// contains filtered or unexported fields
}
LayeredRegistry layers a cache WorkerRegistry over a primary (see #287, parent #262). The primary is the source of truth (Postgres in production); the cache is an optional optimization (Redis).
Reads: cache first; on miss, fall back to primary and populate the cache on the way out.
Writes: primary first; cache mirrored best-effort. Cache errors are swallowed inside the concrete stores, so LayeredRegistry just calls both — the primary operation's outcome is the one surfaced.
func NewLayeredRegistry ¶ added in v0.0.4
func NewLayeredRegistry(primary, cache WorkerRegistry) *LayeredRegistry
func (*LayeredRegistry) Delete ¶ added in v0.0.4
func (r *LayeredRegistry) Delete(workerID string)
func (*LayeredRegistry) Get ¶ added in v0.0.4
func (r *LayeredRegistry) Get(workerID string) (string, bool)
func (*LayeredRegistry) Set ¶ added in v0.0.4
func (r *LayeredRegistry) Set(workerID, addr string)
type MemoryRegistry ¶ added in v0.0.3
type MemoryRegistry struct {
// contains filtered or unexported fields
}
MemoryRegistry is a concurrent in-memory implementation of WorkerRegistry.
func NewMemoryRegistry ¶ added in v0.0.3
func NewMemoryRegistry() *MemoryRegistry
func (*MemoryRegistry) Delete ¶ added in v0.0.3
func (r *MemoryRegistry) Delete(workerID string)
func (*MemoryRegistry) Get ¶ added in v0.0.3
func (r *MemoryRegistry) Get(workerID string) (string, bool)
func (*MemoryRegistry) Set ¶ added in v0.0.3
func (r *MemoryRegistry) Set(workerID, addr string)
type PostgresRegistry ¶ added in v0.0.4
type PostgresRegistry struct {
// contains filtered or unexported fields
}
PostgresRegistry implements WorkerRegistry against the blockyard_workers table, making Postgres the source of truth for the worker address lookup (see #287, parent #262). The same table also backs server.PostgresWorkerMap; each store updates its own column set via upserts, so a production spawn that calls Workers.Set before Registry.Set converges to a full row.
registryTTL mirrors the Redis TTL semantic: a worker whose last_heartbeat is older than registryTTL is treated as gone (Get returns not-found). The health poller calls Set on every successful probe, which bumps last_heartbeat back to now().
func NewPostgresRegistry ¶ added in v0.0.4
func NewPostgresRegistry(db *sqlx.DB, registryTTL time.Duration) *PostgresRegistry
func (*PostgresRegistry) Delete ¶ added in v0.0.4
func (r *PostgresRegistry) Delete(workerID string)
func (*PostgresRegistry) Get ¶ added in v0.0.4
func (r *PostgresRegistry) Get(workerID string) (string, bool)
func (*PostgresRegistry) Set ¶ added in v0.0.4
func (r *PostgresRegistry) Set(workerID, addr string)
type RedisRegistry ¶ added in v0.0.3
type RedisRegistry struct {
// contains filtered or unexported fields
}
RedisRegistry implements WorkerRegistry using simple Redis strings.
Key schema:
{prefix}registry:{workerID} -> string "host:port"
Each key has a TTL equal to registryTTL. The health poller refreshes the TTL on every successful check by calling Set again.
func NewRedisRegistry ¶ added in v0.0.3
func NewRedisRegistry(client *redisstate.Client, registryTTL time.Duration) *RedisRegistry
func (*RedisRegistry) Delete ¶ added in v0.0.3
func (r *RedisRegistry) Delete(workerID string)
func (*RedisRegistry) Get ¶ added in v0.0.3
func (r *RedisRegistry) Get(workerID string) (string, bool)
func (*RedisRegistry) Set ¶ added in v0.0.3
func (r *RedisRegistry) Set(workerID, addr string)
type WorkerRegistry ¶ added in v0.0.3
type WorkerRegistry interface {
Get(workerID string) (string, bool)
Set(workerID string, addr string)
Delete(workerID string)
}
WorkerRegistry defines the contract for worker address lookup. MemoryRegistry is the in-process implementation; Redis implements the same interface for shared state during rolling updates.