system

package
v0.3.24 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2023 License: Apache-2.0 Imports: 35 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
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:

View Source
var MaxStderrFileLength = 1 * datasize.GB

MaxStderrFileLength sets the max size for stderr file during container execution (needed to prevent DoS)

View Source
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)

View Source
var MaxStdoutFileLength = 1 * datasize.GB

MaxStdoutFileLength sets the max size for stdout file during container execution (needed to prevent DoS)

View Source
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)

View Source
var Stderr = struct{ io.Writer }{os.Stderr}
View Source
var Stdout = struct{ io.Writer }{os.Stdout}

Functions

func AddJobIDFromBaggageToSpan

func AddJobIDFromBaggageToSpan(ctx context.Context, span oteltrace.Span)

func AddJobIDToBaggage

func AddJobIDToBaggage(ctx context.Context, jobID string) context.Context

func AddNodeIDToBaggage

func AddNodeIDToBaggage(ctx context.Context, nodeID string) context.Context

func FindJobIDInTestOutput

func FindJobIDInTestOutput(testOutput string) string

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 GetShortID(ID string) string

func GetTracer

func GetTracer() oteltrace.Tracer

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 NewRootSpan(ctx context.Context, t oteltrace.Tracer, name string) (context.Context, oteltrace.Span)

func PathExists

func PathExists(path string) (bool, error)

PathExists returns whether the given file or directory exists

func PublicKeyMatchesID

func PublicKeyMatchesID(publicKey, clientID string) (bool, error)

PublicKeyMatchesID returns true if the given base64-encoded public key and the given client ID correspond to each other:

func ReverseList

func ReverseList(s []string) []string

func SignForClient

func SignForClient(msg []byte) (string, error)

SignForClient signs a message with the user's private ID key. NOTE: must be called after InitConfig() or system will panic.

func 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 SplitLines(s string) []string

func ValidateWorkingDir

func ValidateWorkingDir(jobWorkingDir string) error

Function for validating the workdir of a docker command.

func Verify

func Verify(msg []byte, sig, publicKey string) error

Verify verifies a signed message with the given encoding of a public key. Returns non nil if the key is invalid.

func VerifyForClient

func VerifyForClient(msg []byte, sig string) (bool, error)

VerifyForClient verifies a signed message with the user's public ID key. NOTE: must be called after InitConfig() or system will panic.

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 FunctionWaiter struct {
	Name        string
	MaxAttempts int
	Delay       time.Duration
	Handler     func() (bool, error)
}

func (*FunctionWaiter) Wait

func (waiter *FunctionWaiter) Wait(ctx context.Context) error

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

func (*JobLifecycleEventHandler) HandleConsumedJobEvent

func (t *JobLifecycleEventHandler) HandleConsumedJobEvent(ctx context.Context, event model.JobEvent) error

func (*JobLifecycleEventHandler) HandlePublishedJobEvent

func (t *JobLifecycleEventHandler) HandlePublishedJobEvent(ctx context.Context, event model.JobEvent) error

Jump to

Keyboard shortcuts

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