Documentation
¶
Overview ¶
Utilities ¶
Module wide utilities, at the moment only shared grpc constants for healthcheck.
Index ¶
- Constants
- Variables
- func Clamp[X cmp.Ordered](x, lowerBound, upperBound X) X
- func HashPath(path []byte) string
- func MapMount(dir string, mounts MountMap) (string, bool)
- func NewSampler(conf *config.OtelDropSamplingConfig, next sdktrace.Sampler) (sdktrace.Sampler, error)
- func ParseAddrPort(ctx context.Context, logger log.Logger, configCheck bool, rawAddrPort string) (netip.AddrPort, error)
- func RandomName() (string, error)
- func SSVString(ssv ServerStateValue) string
- func SameStatus(err, target error) bool
- func ValidatePrefix(prefix string) bool
- type ComponentState
- type HealthService
- type MountMap
- type NotifierChan
- type OffsetTime
- type ReadyNotifier
- type ReadyReceiver
- type RoleState
- func (rs *RoleState) AwaitStartup(ctx context.Context, logger log.Logger) bool
- func (rs *RoleState) Enabled(role config.ISMRole) bool
- func (rs *RoleState) Notifier(role config.ISMRole) ReadyNotifier
- func (rs *RoleState) NotifyStop(logger log.Logger)
- func (rs *RoleState) Ready(role config.ISMRole) ReadyReceiver
- func (rs *RoleState) String() string
- type RollingCounter
- type Server
- type ServerState
- type ServerStateValue
- type ServerUpdate
- type StaticProvider
- type SystemTime
- type TimeProvider
- type Tracer
Constants ¶
const NameLength = 5
/ Generate a random name inspired by https://stackoverflow.com/a/46909816
Variables ¶
var ( // static HealthCheckResponse{Status: health.HealthCheckResponse_SERVING} HealthyResp = &health.HealthCheckResponse{Status: health.HealthCheckResponse_SERVING} // static HealthCheckResponse{Status: health.HealthCheckResponse_NOT_SERVING} DegradedResp = &health.HealthCheckResponse{Status: health.HealthCheckResponse_NOT_SERVING} // error for unsupported HealthServices ErrServiceNotFound = status.Error(codes.NotFound, "service not found") ErrLogicRace = status.Error(codes.Internal, "unexpected state encountered") // error for env removal suppressed by config ErrEnvRemovalUnsupported = status.Error(codes.FailedPrecondition, "environment removal is not supported") )
var (
ErrConnectionTimeout = status.Error(codes.DeadlineExceeded, "timeout during initial connection")
)
var ISMRev = func() string { info, ok := debug.ReadBuildInfo() if ok && info.Main.Version != "" { rev := "ism" for _, val := range info.Settings { switch val.Key { case "vcs.revision": rev += "-" + val.Value case "vcs.modified": rev += "-dirty" } } if rev == "ism" { return "(devel)" } else { return rev } } else { return "(devel)" } }()
build info for identification flags
Functions ¶
func Clamp ¶
clamp value to x \in [lowerBound, upperBound]
func MapMount ¶
helper for Executor.MapMount on a static mount map
func NewSampler ¶
func ParseAddrPort ¶
func ParseAddrPort( ctx context.Context, logger log.Logger, configCheck bool, rawAddrPort string, ) (netip.AddrPort, error)
parse a string of `[host]:[port]`
func SSVString ¶
func SSVString(ssv ServerStateValue) string
func SameStatus ¶
checks if a gRPC error and golang error have the same contents
Types ¶
type ComponentState ¶
type ComponentState struct {
Ready chan struct{} // channel for awaiting component startup, if nil == component is disables
}
state of individual component, like broker or api
func (*ComponentState) Enabled ¶
func (cs *ComponentState) Enabled() bool
type HealthService ¶
type HealthService = string
supported grpc healthcheck services
var ( BrokerHealthService HealthService = "broker" // the broker, effectively the pool status ActiveInstanceService HealthService = "active" // the active instance BackupInstanceService HealthService = "backup" // the backup/replicate instance // collection of supported grpc healthcheck services HealthServices = []HealthService{ BrokerHealthService, ActiveInstanceService, BackupInstanceService, } )
type MountMap ¶
map of path prefixes -> replacement prefixes
type NotifierChan ¶
type NotifierChan = chan struct{}
type OffsetTime ¶
type OffsetTime struct {
// contains filtered or unexported fields
}
provider that passes through time.Now with a fixed offset
func (*OffsetTime) Skip ¶
func (ot *OffsetTime) Skip(offset time.Duration)
increments internal timer offset
type ReadyNotifier ¶
type ReadyNotifier = chan<- struct{}
type ReadyReceiver ¶
type ReadyReceiver = <-chan struct{}
type RoleState ¶
type RoleState struct {
// contains filtered or unexported fields
}
container for state of each component
func NewRoleState ¶
create new role states from config values for roles NOTE: will panic if any role is not a valid ISMRole
func (*RoleState) AwaitStartup ¶
await startup of all roles and try to invoke sd_notify
func (*RoleState) Enabled ¶
check if role is enabled NOTE: will panic if role is not a valid ISMRole
func (*RoleState) Notifier ¶
func (rs *RoleState) Notifier(role config.ISMRole) ReadyNotifier
return channel that will reflect readiness of role
func (*RoleState) NotifyStop ¶
try use sd_notify to inform of shutdown
func (*RoleState) Ready ¶
func (rs *RoleState) Ready(role config.ISMRole) ReadyReceiver
return channel that will reflect readiness of role
type RollingCounter ¶
type RollingCounter struct {
// contains filtered or unexported fields
}
rolling counter that records success/failure for configurable window of `window` seconds
func NewRollingCounter ¶
func NewRollingCounter(provider TimeProvider, size, window int64) (*RollingCounter, error)
func (*RollingCounter) Percentage ¶
func (rc *RollingCounter) Percentage() (uint, float32)
return number of results and percentage of failed results in current window
func (*RollingCounter) Record ¶
func (rc *RollingCounter) Record(result bool)
record a new result for the current window
type Server ¶
type Server struct {
ID string // internal identifier
Password []byte // isabelle password
Addr netip.AddrPort // server address for clients
ClientCount atomic.Int32 // number of connected clients
State ServerState // state of the server
MonitorClient *isync.SyncClient // client for active monitoring
LogMessages chan string // channel where log messages are forwarded
CreationTime time.Time // time of container creation (unix timestamp)
}
reference to service instance
type ServerState ¶
type ServerState struct {
// contains filtered or unexported fields
}
Internal server state, formerly known as ready and healthy flags
func (*ServerState) CompareAndSwap ¶
func (s *ServerState) CompareAndSwap(old ServerStateValue, new ServerStateValue) (swapped bool)
func (*ServerState) Load ¶
func (s *ServerState) Load() ServerStateValue
func (*ServerState) Store ¶
func (s *ServerState) Store(newValue ServerStateValue)
func (*ServerState) String ¶
func (s *ServerState) String() string
type ServerStateValue ¶
type ServerStateValue = byte
const ( ServerUnknown ServerStateValue = iota // server state not known ServerStarting // server is starting but not ready to accept connections ServerReady // server is ready to accept new connections ServerUnhealthy // server should not accept new connections and be terminated ServerShutdown // server has been shutdown, should only be used as part of ServerUpdate )
type ServerUpdate ¶
type ServerUpdate struct {
ID string // server id, should correspond to a known Server.ID
State ServerStateValue // new state of server
}
unit status update, should be received on rcfg.Updates after a call to Executor.Refresh
type StaticProvider ¶
type StaticProvider struct {
// contains filtered or unexported fields
}
static provider with fixed time.Time, guaranteed to be monotonically increasing
func NewStaticProvider ¶
func NewStaticProvider(now time.Time) *StaticProvider
func (*StaticProvider) Step ¶
func (sp *StaticProvider) Step(step time.Duration)
advance internal timer by `step`, will panic if `step` is negative
Source Files
¶
- containers.go
- counter.go
- grpc.go
- info.go
- logger.go
- net.go
- otel.go
- server.go
- time.go