Documentation
¶
Index ¶
- Constants
- func AdvancedDivide[T numbers](a, b T) T
- 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 GetHTTPClient() *http.Client
- func GetHTTPSClient(ctx context.Context, certPath, name, ca, cert, key string) (*http.Client, error)
- func GetOutboundAddress(bind, probeTarget string) (string, error)
- func GetUnixSockClient() *http.Client
- func LabelsFilter(extend, labels map[string]string) bool
- 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 NewInheritCtx(ctx context.Context) context.Context
- 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 ParseWorkloadName(workloadName string) (string, string, string, error)
- func RandomString(n int) string
- func Range(n int) []int
- func Round(f float64) float64
- func SHA256(input string) string
- func SentryGo(f func())
- func ShortID(workloadID string) string
- func Tail(path string) string
- func TempFile(stream io.ReadCloser) (name string, err error)
- func Txn(ctx context.Context, cond, then contextFunc, rollback rollbackFunc, ...) (txnErr error)
- func WithTimeout(ctx context.Context, timeout time.Duration, f func(context.Context))
- type Statsd
Constants ¶
const (
// DefaultVersion is the image tag assumed when a reference carries none.
DefaultVersion = "latest"
)
Variables ¶
This section is empty.
Functions ¶
func AdvancedDivide ¶
func AdvancedDivide[T numbers](a, b T) T
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 GetHTTPClient ¶
func GetHTTPSClient ¶
func GetHTTPSClient(ctx context.Context, certPath, name, ca, cert, key string) (*http.Client, error)
GetHTTPSClient returns a per-cert cached HTTPS client, or the plain HTTP client when any of certPath/ca/cert/key is empty.
func GetOutboundAddress ¶
GetOutboundAddress returns bind, or the local IP reaching probeTarget when bind's host is unspecified.
func GetUnixSockClient ¶
func LabelsFilter ¶
LabelsFilter reports whether every key/value in labels is present in extend.
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 NewInheritCtx ¶
NewInheritCtx returns ctx with its values but without its cancellation.
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 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.
func TempFile ¶
func TempFile(stream io.ReadCloser) (name string, err error)
TempFile copies stream into a new temp file, closes stream, and returns the file name.
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.