Documentation ¶
Index ¶
- Variables
- func AddJobIDFromBaggageToSpan(ctx context.Context, span oteltrace.Span)
- func AddJobIDToBaggage(ctx context.Context, jobID string) context.Context
- func AddNodeIDToBaggage(ctx context.Context, nodeID string) context.Context
- func FindJobIDInTestOutput(testOutput string) string
- func GetClientID() string
- func GetClientPublicKey() string
- func GetShortID(ID string) string
- func GetTracer() oteltrace.Tracer
- func InitConfig() error
- func InitConfigForTesting(t testingT)
- func Max[T constraints.Ordered](a, b T) T
- func Min[T constraints.Ordered](a, b T) T
- func NewRootSpan(ctx context.Context, t oteltrace.Tracer, name string) (context.Context, oteltrace.Span)
- func NewSpan(ctx context.Context, t oteltrace.Tracer, name string, ...) (context.Context, oteltrace.Span)
- func PathExists(path string) (bool, error)
- func PublicKeyMatchesID(publicKey, clientID string) (bool, error)
- func ReverseList(s []string) []string
- func SignForClient(msg []byte) (string, error)
- func Span(ctx context.Context, spanName string, opts ...oteltrace.SpanStartOption) (context.Context, oteltrace.Span)
- func SplitLines(s string) []string
- func ValidateWorkingDir(jobWorkingDir string) error
- func Verify(msg []byte, sig, publicKey string) error
- func VerifyForClient(msg []byte, sig string) (bool, error)
- type CleanupManager
- type Environment
- type EnvironmentData
- type FunctionWaiter
- type JobLifecycleEventHandler
Constants ¶
This section is empty.
Variables ¶
var Envs = map[Environment]EnvironmentData{ EnvironmentProd: { APIPort: 1234, APIHost: "bootstrap.production.bacalhau.org", BootstrapAddresses: []string{ "/ip4/35.245.115.191/tcp/1235/p2p/QmdZQ7ZbhnvWY1J12XYKGHApJ6aufKyLNSvf8jZBrBaAVL", "/ip4/35.245.61.251/tcp/1235/p2p/QmXaXu9N5GNetatsvwnTfQqNtSeKAD6uCmarbh3LMRYAcF", "/ip4/35.245.251.239/tcp/1235/p2p/QmYgxZiySj3MRkwLSL4X2MF5F9f2PMhAE3LV49XkfNL1o3", }, IPFSSwarmAddresses: []string{ "/ip4/35.245.115.191/tcp/1235/p2p/QmdZQ7ZbhnvWY1J12XYKGHApJ6aufKyLNSvf8jZBrBaAVL", "/ip4/35.245.61.251/tcp/1235/p2p/QmXaXu9N5GNetatsvwnTfQqNtSeKAD6uCmarbh3LMRYAcF", "/ip4/35.245.251.239/tcp/1235/p2p/QmYgxZiySj3MRkwLSL4X2MF5F9f2PMhAE3LV49XkfNL1o3", }, }, EnvironmentDev: { APIPort: 1234, APIHost: "bootstrap.development.bacalhau.org", BootstrapAddresses: []string{ "/ip4/34.88.135.65/tcp/1235/p2p/QmfRDVYnEcPassyJFGQw8Wt4t9QuA843uuKPVNEVNm4Smo", "/ip4/35.228.112.50/tcp/1235/p2p/QmQM1yRXyKGAfFtYpPSy5grHSief3fic6YjLEWQYpmiGTM", }, IPFSSwarmAddresses: []string{ "/ip4/34.88.135.65/tcp/1235/p2p/QmfRDVYnEcPassyJFGQw8Wt4t9QuA843uuKPVNEVNm4Smo", "/ip4/35.228.112.50/tcp/1235/p2p/QmQM1yRXyKGAfFtYpPSy5grHSief3fic6YjLEWQYpmiGTM", }, }, EnvironmentStaging: { APIPort: 1234, APIHost: "bootstrap.staging.bacalhau.org", BootstrapAddresses: []string{ "/ip4/34.125.80.77/tcp/1235/p2p/QmRbFXwNRamB8z3SXvSg6KPCHGDAyYKjggARU1KBTxWeMz", "/ip4/34.125.130.185/tcp/1235/p2p/QmTRsYgLck8RHedBdZijjA8jPfkSKjmUwVu2k9iUXJ7SLp", "/ip4/34.125.197.225/tcp/1235/p2p/QmS8wQaZqyRXP83rZQtNsmLzgU9ZJYxAVVTDETFdEFZXGA", }, IPFSSwarmAddresses: []string{ "/ip4/34.125.80.77/tcp/1235/p2p/QmRbFXwNRamB8z3SXvSg6KPCHGDAyYKjggARU1KBTxWeMz", "/ip4/34.125.130.185/tcp/1235/p2p/QmTRsYgLck8RHedBdZijjA8jPfkSKjmUwVu2k9iUXJ7SLp", "/ip4/34.125.197.225/tcp/1235/p2p/QmS8wQaZqyRXP83rZQtNsmLzgU9ZJYxAVVTDETFdEFZXGA", }, }, }
Envs is a list of environment data for various environments:
var MaxStderrFileLength = 1 * datasize.GB
MaxStderrFileLength sets the max size for stderr file during container execution (needed to prevent DoS)
var MaxStderrReturnLength = 2 * datasize.KB
MaxStderrReturnLength sets the max size for stderr string return into RunOutput (with trunctation) from container execution (needed to prevent DoS)
var MaxStdoutFileLength = 1 * datasize.GB
MaxStdoutFileLength sets the max size for stdout file during container execution (needed to prevent DoS)
var MaxStdoutReturnLength = 2 * datasize.KB
MaxStdoutReturnLength sets the max size for stdout string return into RunOutput (with trunctation) from container execution (needed to prevent DoS)
var Stderr = struct{ io.Writer }{os.Stderr}
var Stdout = struct{ io.Writer }{os.Stdout}
Functions ¶
func AddNodeIDToBaggage ¶
func FindJobIDInTestOutput ¶
func GetClientID ¶
func GetClientID() string
GetClientID returns a hash identifying a user based on their ID key. NOTE: must be called after InitConfig() or system will panic.
func GetClientPublicKey ¶
func GetClientPublicKey() string
GetClientPublicKey returns a base64-encoding of the user's public ID key: NOTE: must be called after InitConfig() or system will panic.
func GetShortID ¶
func InitConfig ¶
func InitConfig() error
InitConfig ensures that a bacalhau config file exists and loads it. NOTE: this will override the global config cache if called twice.
func InitConfigForTesting ¶
func InitConfigForTesting(t testingT)
InitConfigForTesting creates a fresh config setup in a temporary directory for testing config-related stuff and user ID message signing.
func Max ¶
func Max[T constraints.Ordered](a, b T) T
func Min ¶
func Min[T constraints.Ordered](a, b T) T
func NewRootSpan ¶
func PathExists ¶
PathExists returns whether the given file or directory exists
func PublicKeyMatchesID ¶
PublicKeyMatchesID returns true if the given base64-encoded public key and the given client ID correspond to each other:
func ReverseList ¶
func SignForClient ¶
SignForClient signs a message with the user's private ID key. NOTE: must be called after InitConfig() or system will panic.
func Span ¶
func Span(ctx context.Context, spanName string, opts ...oteltrace.SpanStartOption) (context.Context, oteltrace.Span)
Span creates and starts a new span, and a context containing it. For more information see the otel.Tracer.Start(...) docs: https://pkg.go.dev/go.opentelemetry.io/otel/trace#Tracer ctx: the context to use for the span tracerName: the name of the service that the span is for - will be prefixed with "tracer/". Will create a new one if one with the same name does not exist spanName: the name of the span, inside the service opts: additional options to configure the span from trace.SpanStartOption
func SplitLines ¶
func ValidateWorkingDir ¶
Function for validating the workdir of a docker command.
Types ¶
type CleanupManager ¶
type CleanupManager struct {
// contains filtered or unexported fields
}
CleanupManager provides utilities for ensuring that sub-goroutines can clean up their resources before the main goroutine exits. Can be used to register callbacks for long-running system processes.
func NewCleanupManager ¶
func NewCleanupManager() *CleanupManager
NewCleanupManager returns a new CleanupManager instance.
func (*CleanupManager) Cleanup ¶
func (cm *CleanupManager) Cleanup(ctx context.Context)
Cleanup runs all registered clean-up functions in sub-goroutines and waits for them all to complete before exiting.
func (*CleanupManager) RegisterCallback ¶
func (cm *CleanupManager) RegisterCallback(fn cleanUpWithoutContext)
RegisterCallback registers a clean-up function.
func (*CleanupManager) RegisterCallbackWithContext ¶
func (cm *CleanupManager) RegisterCallbackWithContext(fn cleanUpWithContext)
RegisterCallbackWithContext registers a clean-up function. The context passed is guaranteed not to be already canceled.
type Environment ¶
type Environment string
const ( // Known environments that are configured in ops/terraform: EnvironmentStaging Environment = "staging" EnvironmentProd Environment = "production" EnvironmentDev Environment = "development" EnvironmentTest Environment = "test" )
func GetEnvironment ¶
func GetEnvironment() Environment
func (Environment) IsKnown ¶
func (e Environment) IsKnown() bool
func (Environment) String ¶
func (e Environment) String() string
type EnvironmentData ¶
type EnvironmentData struct { // APIHost is the hostname of an environment's public API servers. APIHost string // APIPort is the port that an environment serves the public API on. APIPort int // Bootstrap lists the bacalhau addresses for bootstrapping new local nodes. BootstrapAddresses []string // IPFSSwarmAddresses lists the swarm addresses of an environment's IPFS // nodes, for bootstrapping new local nodes. IPFSSwarmAddresses []string }
EnvironmentData captures data for a particular environment.
type FunctionWaiter ¶
type JobLifecycleEventHandler ¶
type JobLifecycleEventHandler struct {
// contains filtered or unexported fields
}
A job event handler that adds lifecycle events to the job tracing span, both for events consumed and events published.
func NewJobLifecycleEventHandler ¶
func NewJobLifecycleEventHandler(nodeID string) *JobLifecycleEventHandler