Documentation
¶
Index ¶
- func AdvancedDivide(a, b float64) float64
- func Bool2Int(a bool) int
- func CleanStatsdMetrics(k string) string
- func DecodeMetaInLabel(ctx context.Context, labels map[string]string) *types.LabelMeta
- func EncodeMetaInLabel(ctx context.Context, meta *types.LabelMeta) string
- func EncodePublishInfo(info map[string][]string) map[string]string
- func EnsureReaderClosed(ctx context.Context, stream io.ReadCloser)
- func GetGitRepoName(url string) (string, error)
- func GetOutboundAddress(bind, probeTarget string) (string, error)
- func KeepAlive(ctx context.Context, interval time.Duration, ...) error
- func LabelsFilter(extend, labels map[string]string) bool
- func LastEnvValue(env []string, key string) string
- func ListAllExecutableFiles(basedir string) ([]string, error)
- func LoadConfig(configPath string) (types.Config, error)
- func MakeCommandLineArgs(s string) []string
- func MakePublishInfo(networks map[string]string, ports []string) map[string][]string
- func MakeWorkloadName(appname, entrypoint, ident string) string
- func Map[T1, T2 any](slice []T1, f func(T1) T2) []T2
- func MergeHookOutputs(outputs []*bytes.Buffer) []byte
- func NewHealthCheck(check *types.HealthCheck) *enginetypes.HealthCheck
- func NewPool(max int) (*ants.PoolWithFunc, error)
- func PCR(ctx context.Context, prepare, commit, rollback contextFunc, ttl time.Duration) error
- func ParseRAMInHuman(ram string) (int64, error)
- func ParseRate(rate string) int64
- func ParseWorkloadName(workloadName string) (string, string, string, error)
- func RandomID() string
- func RandomString(n int) string
- func Range(n int) []int
- func Round(f float64) float64
- func SentryGo(f func())
- func ShortID(workloadID string) string
- func Tail(path string) string
- func Txn(ctx context.Context, cond, then contextFunc, rollback rollbackFunc, ...) (settled bool, txnErr error)
- func WithTimeout(ctx context.Context, timeout time.Duration, f func(context.Context))
- type Statsd
- type VolumeBind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdvancedDivide ¶
AdvancedDivide returns 0 when either operand is 0.
func CleanStatsdMetrics ¶
CleanStatsdMetrics replaces "." with "-".
func DecodeMetaInLabel ¶
DecodeMetaInLabel returns the meta from labels, or an empty meta when absent or malformed.
func EncodeMetaInLabel ¶
EncodeMetaInLabel returns meta as JSON, or "" when marshaling fails.
func EncodePublishInfo ¶
EncodePublishInfo joins each network's addresses with commas.
func EnsureReaderClosed ¶
func EnsureReaderClosed(ctx context.Context, stream io.ReadCloser)
EnsureReaderClosed drains stream to EOF and closes it; a nil stream is a no-op.
func GetGitRepoName ¶
func GetOutboundAddress ¶
GetOutboundAddress returns bind, or the local IP reaching probeTarget when bind's host is unspecified.
func KeepAlive ¶ added in v0.1.1
func KeepAlive(ctx context.Context, interval time.Duration, refresh func(context.Context) error) error
KeepAlive calls refresh every interval until ctx ends or refresh fails, returning the failure.
func LabelsFilter ¶
LabelsFilter reports whether every key/value in labels is present in extend.
func LastEnvValue ¶ added in v0.1.1
LastEnvValue takes the last value of key, as core appends its own after the client's.
func ListAllExecutableFiles ¶
ListAllExecutableFiles returns the executable files directly under basedir, not recursing.
func LoadConfig ¶
LoadConfig loads the config from the YAML file at configPath.
func MakeCommandLineArgs ¶
MakeCommandLineArgs splits s into argv, honoring single and double quotes.
func MakePublishInfo ¶
MakePublishInfo maps each network to its "ip:port" strings.
func MakeWorkloadName ¶
MakeWorkloadName joins appname, entrypoint, ident using '_'
func Map ¶
func Map[T1, T2 any](slice []T1, f func(T1) T2) []T2
Map returns f applied to every element of slice.
func MergeHookOutputs ¶
func NewHealthCheck ¶ added in v0.1.1
func NewHealthCheck(check *types.HealthCheck) *enginetypes.HealthCheck
NewHealthCheck renders the label's health check the way a workload record carries it.
func NewPool ¶
func NewPool(max int) (*ants.PoolWithFunc, error)
NewPool returns a blocking pool; a full pool makes Invoke wait for a free worker.
func ParseRAMInHuman ¶
ParseRAMInHuman parses a human-readable size ("100KB", "-1T") into bytes.
func ParseRate ¶ added in v0.1.1
ParseRate reads a human byte rate, treating junk and negatives as zero.
func ParseWorkloadName ¶
ParseWorkloadName is the inverse of MakeWorkloadName.
func RandomString ¶
RandomString returns n random letters from [a-zA-Z].
func SentryGo ¶
func SentryGo(f func())
SentryGo runs f in a goroutine and reports a panic to Sentry before re-raising it.
Types ¶
type Statsd ¶
type Statsd struct {
// contains filtered or unexported fields
}
Statsd batches metrics into UDP datagrams and drops send failures.
func NewStatsd ¶
NewStatsd dials the statsd server at addr and flushes buffered metrics every 100ms.
func (*Statsd) Close ¶
Close flushes the buffer, stops the flush ticker and releases the connection.
type VolumeBind ¶ added in v0.1.1
VolumeBind is one host bind parsed from "source:dest[:ro]" after env expansion.
func ParseVolumeBinds ¶ added in v0.1.1
func ParseVolumeBinds(volumes, env []string) []VolumeBind
ParseVolumeBinds keeps the well-formed binds and expands $VAR from env.