Documentation
¶
Index ¶
- Constants
- func Provider(items ...Option) runaprovider.Provider
- type Driver
- type DriverRegistry
- type Instance
- type Option
- func Addr(value string) Option
- func DriverWith(driver Driver) Option
- func Env(value string) Option
- func HeartbeatInterval(value time.Duration) Option
- func ID(value string) Option
- func Meta(key string, value any) Option
- func Service(value string) Option
- func TTL(value time.Duration) Option
- func UseDriver(name string) Option
- func Version(value string) Option
- type Registry
- func (runtime *Registry) Boot(ctx context.Context, app runaprovider.Context) error
- func (runtime *Registry) Init(context.Context, runaprovider.Context) error
- func (runtime *Registry) Instance() Instance
- func (runtime *Registry) Instances(ctx context.Context, service ...string) ([]Instance, error)
- func (runtime *Registry) Name() string
- func (runtime *Registry) Register(context.Context, runaprovider.Context) error
- func (runtime *Registry) Shutdown(ctx context.Context, app runaprovider.Context) error
- type Status
Constants ¶
View Source
const ( DefaultService = "runa" DefaultHeartbeatInterval = 10 * time.Second DefaultTTL = 30 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func Provider ¶
func Provider(items ...Option) runaprovider.Provider
Provider registers optional cluster heartbeat support.
Types ¶
type Driver ¶
type Driver interface {
Name() string
Register(ctx context.Context, instance Instance) error
Heartbeat(ctx context.Context, id string, status Status) error
Unregister(ctx context.Context, id string) error
Instances(ctx context.Context, service string) ([]Instance, error)
Close(ctx context.Context) error
}
Driver stores cluster instance heartbeats.
type DriverRegistry ¶ added in v0.1.2
type DriverRegistry struct {
// contains filtered or unexported fields
}
DriverRegistry stores named cluster drivers contributed by driver subpackages.
func NewDriverRegistry ¶ added in v0.1.2
func NewDriverRegistry() *DriverRegistry
NewDriverRegistry creates a driver registry with the default memory driver.
func (*DriverRegistry) Driver ¶ added in v0.1.2
func (registry *DriverRegistry) Driver(name string) Driver
Driver returns a cluster driver by name.
func (*DriverRegistry) Register ¶ added in v0.1.2
func (registry *DriverRegistry) Register(driver Driver)
Register stores a cluster driver by its own name.
type Instance ¶
type Instance struct {
ID string `json:"id"`
Service string `json:"service"`
Env string `json:"env"`
Version string `json:"version"`
Hostname string `json:"hostname"`
PID int `json:"pid"`
Addr string `json:"addr,omitempty"`
Status Status `json:"status"`
StartedAt time.Time `json:"started_at"`
HeartbeatAt time.Time `json:"heartbeat_at"`
TTL time.Duration `json:"ttl"`
Meta core.Map `json:"meta,omitempty"`
}
Instance describes one running app process.
type Option ¶
type Option func(*options)
Option configures the cluster provider.
func HeartbeatInterval ¶
HeartbeatInterval sets heartbeat interval.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry stores cluster state for one app instance.
func NewRegistry ¶
func NewRegistry(ctx runaprovider.Context, opts options) (*Registry, error)
NewRegistry creates a cluster runtime.
func RegistryOf ¶
func RegistryOf(ctx runaprovider.Context) *Registry
RegistryOf returns the optional cluster runtime from provider context.
Click to show internal directories.
Click to hide internal directories.