host

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2025 License: PostgreSQL Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const UpdateStatusInterval = 15 * time.Second

Variables

This section is empty.

Functions

func Provide

func Provide(i *do.Injector)

Types

type Cohort

type Cohort struct {
	Type             CohortType
	MemberID         string
	ControlAvailable bool
}

type CohortType

type CohortType string
const (
	CohortTypeSwarm CohortType = "swarm"
)

type Host

type Host struct {
	ID                      string
	Orchestrator            config.Orchestrator
	Cohort                  *Cohort
	DataDir                 string
	Hostname                string
	IPv4Address             string
	CPUs                    int
	MemBytes                uint64
	Status                  *HostStatus
	DefaultPgEdgeVersion    *PgEdgeVersion
	SupportedPgEdgeVersions []*PgEdgeVersion
}

func (*Host) Supports

func (h *Host) Supports(pgEdgeVersion *PgEdgeVersion) bool

type HostState

type HostState string
const (
	HostStateHealthy     HostState = "healthy"
	HostStateUnreachable HostState = "unreachable"
	HostStateDegraded    HostState = "degraded"
	HostStateUnknown     HostState = "unknown"
)

type HostStatus

type HostStatus struct {
	HostID     string
	UpdatedAt  time.Time
	State      HostState
	Components map[string]common.ComponentStatus
}

type HostStatusStore

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

func NewHostStatusStore

func NewHostStatusStore(client *clientv3.Client, root string) *HostStatusStore

func (*HostStatusStore) Create

func (*HostStatusStore) DeleteByKey

func (s *HostStatusStore) DeleteByKey(hostID string) storage.DeleteOp

func (*HostStatusStore) GetAll

func (*HostStatusStore) GetByKey

func (s *HostStatusStore) GetByKey(hostID string) storage.GetOp[*StoredHostStatus]

func (*HostStatusStore) GetByKeys

func (s *HostStatusStore) GetByKeys(hostIDs ...string) storage.GetMultipleOp[*StoredHostStatus]

func (*HostStatusStore) Key

func (s *HostStatusStore) Key(hostID string) string

func (*HostStatusStore) Prefix

func (s *HostStatusStore) Prefix() string

func (*HostStatusStore) Put

type HostStore

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

func NewHostStore

func NewHostStore(client *clientv3.Client, root string) *HostStore

func (*HostStore) Create

func (s *HostStore) Create(item *StoredHost) storage.PutOp[*StoredHost]

func (*HostStore) DeleteByKey

func (s *HostStore) DeleteByKey(hostID string) storage.DeleteOp

func (*HostStore) GetAll

func (s *HostStore) GetAll() storage.GetMultipleOp[*StoredHost]

func (*HostStore) GetByKey

func (s *HostStore) GetByKey(hostID string) storage.GetOp[*StoredHost]

func (*HostStore) GetByKeys

func (s *HostStore) GetByKeys(hostIDs ...string) storage.GetMultipleOp[*StoredHost]

func (*HostStore) Key

func (s *HostStore) Key(hostID string) string

func (*HostStore) Prefix

func (s *HostStore) Prefix() string

func (*HostStore) Put

func (s *HostStore) Put(item *StoredHost) storage.PutOp[*StoredHost]

type Orchestrator

type Orchestrator interface {
	PopulateHost(ctx context.Context, h *Host) error
	PopulateHostStatus(ctx context.Context, h *HostStatus) error
}

type PgEdgeVersion

type PgEdgeVersion struct {
	PostgresVersion *Version `json:"postgres_version"`
	SpockVersion    *Version `json:"spock_version"`
}

func GreatestCommonDefaultVersion

func GreatestCommonDefaultVersion(hosts ...*Host) (*PgEdgeVersion, error)

func MustPgEdgeVersion

func MustPgEdgeVersion(postgresVersion, spockVersion string) *PgEdgeVersion

func NewPgEdgeVersion

func NewPgEdgeVersion(postgresVersion, spockVersion string) (*PgEdgeVersion, error)

func (*PgEdgeVersion) Clone

func (v *PgEdgeVersion) Clone() *PgEdgeVersion

func (*PgEdgeVersion) Compare

func (v *PgEdgeVersion) Compare(other *PgEdgeVersion) int

func (*PgEdgeVersion) Equals

func (v *PgEdgeVersion) Equals(other *PgEdgeVersion) bool

func (*PgEdgeVersion) GreaterThan

func (v *PgEdgeVersion) GreaterThan(other *PgEdgeVersion) bool

func (*PgEdgeVersion) LessThan

func (v *PgEdgeVersion) LessThan(other *PgEdgeVersion) bool

func (*PgEdgeVersion) String

func (v *PgEdgeVersion) String() string

type Resources

type Resources struct {
	CPUs     int    `json:"cpus"`
	MemBytes uint64 `json:"mem_bytes"`
}

func DetectResources

func DetectResources() (*Resources, error)

func (Resources) NanoCPUs

func (r Resources) NanoCPUs() int64

type Service

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

func NewService

func NewService(cfg config.Config, etcd etcd.Etcd, store *Store, orchestrator Orchestrator) *Service

func (*Service) GetAllHosts

func (s *Service) GetAllHosts(ctx context.Context) ([]*Host, error)

func (*Service) GetHost

func (s *Service) GetHost(ctx context.Context, hostID string) (*Host, error)

func (*Service) GetHosts

func (s *Service) GetHosts(ctx context.Context, hostIDs []string) ([]*Host, error)

func (*Service) RemoveHost

func (s *Service) RemoveHost(ctx context.Context, hostID string) error

func (*Service) UpdateHost

func (s *Service) UpdateHost(ctx context.Context) error

func (*Service) UpdateHostStatus

func (s *Service) UpdateHostStatus(ctx context.Context) error

type Store

type Store struct {
	Host       *HostStore
	HostStatus *HostStatusStore
	// contains filtered or unexported fields
}

func NewStore

func NewStore(client *clientv3.Client, root string) *Store

func (*Store) Txn

func (s *Store) Txn(ops ...storage.TxnOperation) storage.Txn

type StoredCohort

type StoredCohort struct {
	Type             CohortType `json:"type"`
	MemberID         string     `json:"member_id"`
	ControlAvailable bool       `json:"control_available"`
}

type StoredHost

type StoredHost struct {
	storage.StoredValue
	ID                      string              `json:"id"`
	Orchestrator            config.Orchestrator `json:"type"`
	Cohort                  *StoredCohort       `json:"stored_cohort,omitempty"`
	DataDir                 string              `json:"data_dir"`
	Hostname                string              `json:"hostname"`
	IPv4Address             string              `json:"ipv4_address"`
	CPUs                    int                 `json:"cpus"`
	MemBytes                uint64              `json:"mem_bytes"`
	DefaultPgEdgeVersion    *PgEdgeVersion      `json:"default_version"`
	SupportedPgEdgeVersions []*PgEdgeVersion    `json:"supported_versions"`
}

type StoredHostStatus

type StoredHostStatus struct {
	storage.StoredValue
	HostID     string                            `json:"host_id"`
	UpdatedAt  time.Time                         `json:"updated_at"`
	State      HostState                         `json:"state"`
	Components map[string]common.ComponentStatus `json:"components"`
}

type UpdateTicker

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

func NewUpdateTicker

func NewUpdateTicker(logger zerolog.Logger, svc *Service) *UpdateTicker

func (*UpdateTicker) Shutdown

func (u *UpdateTicker) Shutdown() error

func (*UpdateTicker) Start

func (u *UpdateTicker) Start(ctx context.Context)

type Version

type Version struct {
	Components []uint64 `json:"components"`
}

func ParseVersion

func ParseVersion(s string) (*Version, error)

func (*Version) Clone

func (v *Version) Clone() *Version

func (*Version) Compare

func (v *Version) Compare(other *Version) int

func (*Version) Major

func (v *Version) Major() (uint64, bool)

func (*Version) MarshalText

func (v *Version) MarshalText() (data []byte, err error)

func (*Version) String

func (v *Version) String() string

func (*Version) UnmarshalJSON

func (v *Version) UnmarshalJSON(data []byte) error

func (*Version) UnmarshalText

func (v *Version) UnmarshalText(data []byte) error

Jump to

Keyboard shortcuts

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