system

package
v1.1.5-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2023 License: Apache-2.0 Imports: 28 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.161.250/tcp/1235/p2p/QmbxGSsM6saCTyKkiWSxhJCt6Fgj7M9cns1vzYtfDbB5Ws",
			"/ip4/34.86.254.26/tcp/1235/p2p/QmeXjeQDinxm7zRiEo8ekrJdbs7585BM6j7ZeLVFrA7GPe",
			"/ip4/35.245.215.155/tcp/1235/p2p/QmPLPUUjaVE3wQNSSkxmYoaBPHVAWdjBjDYmMkWvtMZxAf",
		},
		IPFSSwarmAddresses: []string{
			"/ip4/35.245.161.250/tcp/4001/p2p/12D3KooWAQpZzf3qiNxpwizXeArGjft98ZBoMNgVNNpoWtKAvtYH",
			"/ip4/35.245.161.250/udp/4001/quic/p2p/12D3KooWAQpZzf3qiNxpwizXeArGjft98ZBoMNgVNNpoWtKAvtYH",
			"/ip4/34.86.254.26/tcp/4001/p2p/12D3KooWLfFBjDo8dFe1Q4kSm8inKjPeHzmLBkQ1QAjTHocAUazK",
			"/ip4/34.86.254.26/udp/4001/quic/p2p/12D3KooWLfFBjDo8dFe1Q4kSm8inKjPeHzmLBkQ1QAjTHocAUazK",
			"/ip4/35.245.215.155/tcp/4001/p2p/12D3KooWH3rxmhLUrpzg81KAwUuXXuqeGt4qyWRniunb5ipjemFF",
			"/ip4/35.245.215.155/udp/4001/quic/p2p/12D3KooWH3rxmhLUrpzg81KAwUuXXuqeGt4qyWRniunb5ipjemFF",
			"/ip4/34.145.201.224/tcp/4001/p2p/12D3KooWBCBZnXnNbjxqqxu2oygPdLGseEbfMbFhrkDTRjUNnZYf",
			"/ip4/34.145.201.224/udp/4001/quic/p2p/12D3KooWBCBZnXnNbjxqqxu2oygPdLGseEbfMbFhrkDTRjUNnZYf",
			"/ip4/35.245.41.51/tcp/4001/p2p/12D3KooWJM8j97yoDTb7B9xV1WpBXakT4Zof3aMgFuSQQH56rCXa",
			"/ip4/35.245.41.51/udp/4001/quic/p2p/12D3KooWJM8j97yoDTb7B9xV1WpBXakT4Zof3aMgFuSQQH56rCXa",
		},
	},
	EnvironmentDev: {
		APIPort: 1234,
		APIHost: "bootstrap.development.bacalhau.org",
		BootstrapAddresses: []string{
			"/ip4/34.86.177.175/tcp/1235/p2p/QmfYBQ3HouX9zKcANNXbgJnpyLpTYS9nKBANw6RUQKZffu",
			"/ip4/35.245.221.171/tcp/1235/p2p/QmNjEQByyK8GiMTvnZqGyURuwXDCtzp9X6gJRKkpWfai7S",
		},
		IPFSSwarmAddresses: []string{
			"/ip4/34.86.177.175/tcp/4001/p2p/12D3KooWMSdbPzUf8WWkEcjxpCzkUfToasP9wRjFHy2iCZ6iiZdV",
			"/ip4/34.86.177.175/udp/4001/quic/p2p/12D3KooWMSdbPzUf8WWkEcjxpCzkUfToasP9wRjFHy2iCZ6iiZdV",
			"/ip4/35.245.221.171/tcp/4001/p2p/12D3KooWRBYMhTF6MNh6eN84xcZtg6EX2wJguqEtRTNq4C7aytbu",
			"/ip4/35.245.221.171/udp/4001/quic/p2p/12D3KooWRBYMhTF6MNh6eN84xcZtg6EX2wJguqEtRTNq4C7aytbu",
		},
	},
	EnvironmentStaging: {
		APIPort: 1234,
		APIHost: "bootstrap.staging.bacalhau.org",
		BootstrapAddresses: []string{
			"/ip4/34.85.228.65/tcp/1235/p2p/QmafZ9oCXCJZX9Wt1nhrGS9FVVq41qhcBRSNWCkVhz3Nvv",
			"/ip4/34.86.73.105/tcp/1235/p2p/QmVHCeiLzhFJPCyCj5S1RTAk1vBEvxd8r5A6E4HyJGQtbJ",
			"/ip4/34.150.138.100/tcp/1235/p2p/QmRr9qPTe4mU7aS9faKnWgvn1NtXt36FT8YUULRPCn2f3K",
		},
		IPFSSwarmAddresses: []string{
			"/ip4/34.85.228.65/tcp/4001/p2p/12D3KooWCWSTjjWh7SVoVv24W47z3T1Ly1tgnwZ56CCqCku5e4dS",
			"/ip4/34.85.228.65/udp/4001/quic/p2p/12D3KooWCWSTjjWh7SVoVv24W47z3T1Ly1tgnwZ56CCqCku5e4dS",
			"/ip4/34.86.73.105/tcp/4001/p2p/12D3KooWQuhW3LSpvhea25Zed47Z7fD5Cq2nw1xmapQ2tAUJ3q4F",
			"/ip4/34.86.73.105/udp/4001/quic/p2p/12D3KooWQuhW3LSpvhea25Zed47Z7fD5Cq2nw1xmapQ2tAUJ3q4F",
			"/ip4/34.150.138.100/tcp/4001/p2p/12D3KooWQm1T8EN8fMBz7rLviHxTGdRnohZ9nDPGbW4bfi78ckVT",
			"/ip4/34.150.138.100/udp/4001/quic/p2p/12D3KooWQm1T8EN8fMBz7rLviHxTGdRnohZ9nDPGbW4bfi78ckVT",
			"/ip4/35.245.247.85/tcp/4001/p2p/12D3KooWEztGEJtqtzy7th2d7cTw2iR4CQCPHFUYvj66rhh9Cf7h",
			"/ip4/35.245.247.85/udp/4001/quic/p2p/12D3KooWEztGEJtqtzy7th2d7cTw2iR4CQCPHFUYvj66rhh9Cf7h",
		},
	},
	EnvironmentTest: {
		APIPort: 9999,
		APIHost: "test",
		BootstrapAddresses: []string{
			"/ip4/0.0.0.0/tcp/1235/p2p/QmafZ9oCXCJZX9Wt1nhrGS9FVVq41qhcBRSNWCkVhz3Nvv",
		},
		IPFSSwarmAddresses: []string{
			"/ip4/0.0.0.0/tcp/1235/p2p/QmafZ9oCXCJZX9Wt1nhrGS9FVVq41qhcBRSNWCkVhz3Nvv",
		},
	},
}

Envs is a list of environment data for various environments: Deprecated: stop using this, and use the config file.

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 FindJobIDInTestOutputLegacy added in v1.1.0

func FindJobIDInTestOutputLegacy(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 GetTracer

func GetTracer() oteltrace.Tracer

func MustParseURL added in v0.3.25

func MustParseURL(uri string) *url.URL

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 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 uint16

	// 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