util

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2022 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DBConn                   = "DIREKTIV_DB"
	DirektivDebug            = "DIREKTIV_DEBUG"
	DirektivServiceNamespace = "DIREKTIV_SERVICE_NAMESPACE"
	DirektivNamespace        = "DIREKTIV_NAMESPACE"

	DirektivFlowEndpoint      = "DIREKTIV_FLOW_ENDPOINT"
	DirektivFunctionsEndpoint = "DIREKTIV_FUNCTIONS_ENDPOINT"
	DirektivIngressEndpoint   = "DIREKTIV_INTERNAL_ENDPOINT"

	DirektivLogJSON       = "DIREKTIV_LOG_JSON"
	DirektivOpentelemetry = "DIREKTIV_OTLP"
)

Environtment variable keys

View Source
const (
	InodeTypeGit       = "git"
	InodeTypeDirectory = "directory"
	InodeTypeWorkflow  = "workflow"
)
View Source
const (
	InstanceStatusPending  = "pending"
	InstanceStatusFailed   = "failed"
	InstanceStatusCrashed  = "crashed"
	InstanceStatusComplete = "complete"
)
View Source
const (
	MirrorActivityTypeInit        = "init"
	MirrorActivityTypeReconfigure = "reconfigure"
	MirrorActivityTypeLocked      = "locked"
	MirrorActivityTypeUnlocked    = "unlocked"
	MirrorActivityTypeCronSync    = "scheduled-sync"
	MirrorActivityTypeSync        = "sync"
)
View Source
const (
	MirrorActivityStatusComplete  = "complete"
	MirrorActivityStatusPending   = "pending"
	MirrorActivityStatusExecuting = "executing"
	MirrorActivityStatusFailed    = "failed"
)
View Source
const NameRegexFragment = `(([a-z][a-z0-9_\-\.]*[a-z0-9])|([a-z]))`
View Source
const NameRegexPattern = `^` + NameRegexFragment + `$`
View Source
const RefRegexFragment = `(([a-zA-Z0-9][a-zA-Z0-9_\-\.]*[a-zA-Z0-9])|([a-zA-Z0-9]))`
View Source
const RefRegexPattern = `^` + RefRegexFragment + `$`
View Source
const RegexPattern = NameRegexPattern
View Source
const URIRegexPattern = `^(` + NameRegexFragment + `[\/]?)*$`
View Source
const VarNameRegexPattern = `^(([a-zA-Z][a-zA-Z0-9_\-\.]*[a-zA-Z0-9])|([a-zA-Z]))$`
View Source
const VarRegexPattern = VarNameRegexPattern

Variables

View Source
var TelemetryMiddleware = func(h http.Handler) http.Handler {
	return h
}

Functions

func AddGlobalGRPCDialOption

func AddGlobalGRPCDialOption(opt grpc.DialOption)

func AddGlobalGRPCServerOption

func AddGlobalGRPCServerOption(opt grpc.ServerOption)

func GetEndpointTLS

func GetEndpointTLS(service string) (*grpc.ClientConn, error)

GetEndpointTLS creates a grpc client

func GrpcServerOptions

func GrpcServerOptions(unaryInterceptor grpc.UnaryServerInterceptor, streamInterceptor grpc.StreamServerInterceptor) []grpc.ServerOption

func GrpcStart

func GrpcStart(server **grpc.Server, name, bind string, register func(srv *grpc.Server)) error

GrpcStart starts a grpc server

func InitTelemetry

func InitTelemetry(conf *Config, svcName, imName string) (func(), error)

func MatchesRegex

func MatchesRegex(s string) bool

MatchesRegex responds true if the provided string matches the RegexPattern constant defined in this package.

func MatchesVarRegex

func MatchesVarRegex(s string) bool

func SanitizeAsField

func SanitizeAsField(as string) string

SanitizeAsField removes initial slash if one exists and returns the new value

func Trace

func Trace(ctx context.Context, msg string)

func TraceHTTPRequest

func TraceHTTPRequest(ctx context.Context, r *http.Request) (cleanup func())

func TransplantTelemetryContextInformation

func TransplantTelemetryContextInformation(a, b context.Context) context.Context

Types

type Config

type Config struct {
	FunctionsService string `yaml:"functions-service"`

	// FunctionsTimeout : Action timeout in milliseconds
	FunctionsTimeout int64 `yaml:"functions-timeout"`

	FlowService string `yaml:"flow-service"`

	PrometheusBackend    string `yaml:"prometheus-backend"`
	OpenTelemetryBackend string `yaml:"opentelemetry-backend"`

	Eventing bool `yaml:"eventing"`
}

Config contain direktiv configuration

func ReadConfig

func ReadConfig(file string) (*Config, error)

ReadConfig reads direktiv config file

func (*Config) GetFunctionsTimeout added in v0.6.0

func (cfg *Config) GetFunctionsTimeout() time.Duration

func (*Config) GetTelemetryBackendAddr

func (cfg *Config) GetTelemetryBackendAddr() string

type GenericTelemetryCarrier

type GenericTelemetryCarrier struct {
	Trace map[string]string
}

func (*GenericTelemetryCarrier) Get

func (*GenericTelemetryCarrier) Keys

func (c *GenericTelemetryCarrier) Keys() []string

func (*GenericTelemetryCarrier) Set

func (c *GenericTelemetryCarrier) Set(key, val string)

Jump to

Keyboard shortcuts

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