config

package
v1.5.0-alpha14 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileName = "config.yaml"
)

Variables

View Source
var Default = types.Bacalhau{
	DataDir: defaultDataDir(),
	API: types.API{
		Host: "0.0.0.0",
		Port: 1234,
		Auth: types.AuthConfig{
			Methods: map[string]types.AuthenticatorConfig{
				"ClientKey": {
					Type: "challenge",
				},
			},
		},
	},
	NameProvider: "puuid",
	Orchestrator: types.Orchestrator{
		Enabled: false,
		Host:    "0.0.0.0",
		Port:    4222,
		NodeManager: types.NodeManager{
			DisconnectTimeout: types.Minute,
		},
		Scheduler: types.Scheduler{
			WorkerCount:          runtime.NumCPU(),
			QueueBackoff:         types.Minute,
			HousekeepingInterval: 30 * types.Second,
			HousekeepingTimeout:  2 * types.Minute,
		},
		EvaluationBroker: types.EvaluationBroker{
			VisibilityTimeout: types.Minute,
			MaxRetryCount:     10,
		},
	},
	Compute: types.Compute{
		Enabled:       false,
		Orchestrators: []string{"nats://127.0.0.1:4222"},
		Heartbeat: types.Heartbeat{
			InfoUpdateInterval:     types.Minute,
			ResourceUpdateInterval: 30 * types.Second,
			Interval:               15 * types.Second,
		},
		AllocatedCapacity: types.ResourceScaler{
			CPU:    "70%",
			Memory: "70%",
			Disk:   "70%",
			GPU:    "100%",
		},
	},
	JobDefaults: types.JobDefaults{
		Batch: types.BatchJobDefaultsConfig{
			Priority: 0,
			Task: types.BatchTaskDefaultConfig{
				Resources: types.ResourcesConfig{
					CPU:    "500m",
					Memory: "1Gb",
				},
			},
		},
		Ops: types.BatchJobDefaultsConfig{
			Priority: 0,
			Task: types.BatchTaskDefaultConfig{
				Resources: types.ResourcesConfig{
					CPU:    "500m",
					Memory: "1Gb",
				},
			},
		},
		Daemon: types.LongRunningJobDefaultsConfig{
			Priority: 0,
			Task: types.LongRunningTaskDefaultConfig{
				Resources: types.ResourcesConfig{
					CPU:    "500m",
					Memory: "1Gb",
				},
			},
		},
		Service: types.LongRunningJobDefaultsConfig{
			Priority: 0,
			Task: types.LongRunningTaskDefaultConfig{
				Resources: types.ResourcesConfig{
					CPU:    "500m",
					Memory: "1Gb",
				},
			},
		},
	},
	InputSources: types.InputSourcesConfig{
		ReadTimeout:   5 * types.Minute,
		MaxRetryCount: 3,
	},
	Engines: types.EngineConfig{
		Types: types.EngineConfigTypes{
			Docker: types.Docker{
				ManifestCache: types.DockerManifestCache{
					Size:    1000,
					TTL:     types.Duration(1 * time.Hour),
					Refresh: types.Duration(1 * time.Hour),
				}},
		},
	},
	Publishers: types.PublishersConfig{
		Types: types.PublisherTypes{
			Local: types.LocalPublisher{
				Address: "127.0.0.1",
				Port:    6001,
			},
		},
	},
	JobAdmissionControl: types.JobAdmissionControl{
		Locality: models.Anywhere,
	},
	Logging: types.Logging{
		Level:                "info",
		Mode:                 "default",
		LogDebugInfoInterval: 30 * types.Second,
	},
	UpdateConfig: types.UpdateConfig{
		Interval: types.Day,
	},
	WebUI: types.WebUI{
		Enabled: false,
		Listen:  "0.0.0.0:8438",
	},
}

Default is the default configuration for a bacalhau node.

Functions

func AbsPathSilent added in v1.5.0

func AbsPathSilent(path string) string

func GenerateNodeID added in v1.5.0

func GenerateNodeID(ctx context.Context, nodeNameProviderType string) (string, error)

func KeyAsEnvVar added in v1.0.4

func KeyAsEnvVar(key string) string

KeyAsEnvVar returns the environment variable corresponding to a config key

func MigrateV1 added in v1.5.0

func MigrateV1(in v1types.BacalhauConfig) (types.Bacalhau, error)

func NewTestConfig added in v1.5.0

func NewTestConfig() (types.Bacalhau, error)

NewTestConfig returns a new configuration with the default values for testing.

func NewTestConfigWithOverrides added in v1.5.0

func NewTestConfigWithOverrides(overrides types.Bacalhau) (types.Bacalhau, error)

func ValidatePath added in v1.5.0

func ValidatePath(path string) error

Types

type Config added in v1.5.0

type Config struct {
	// contains filtered or unexported fields
}

func New added in v1.3.2

func New(opts ...Option) (*Config, error)

New returns a configuration with the provided options applied. If no options are provided, the returned config contains only the default values.

func (*Config) ConfigFileUsed added in v1.5.0

func (c *Config) ConfigFileUsed() string

func (*Config) Get added in v1.5.0

func (c *Config) Get(key string) any

func (*Config) Load added in v1.5.0

func (c *Config) Load(path string) error

Load reads in the configuration file specified by `path` overriding any previously set configuration with the values from the read config file. Load returns an error if the file cannot be read.

func (*Config) Paths added in v1.5.0

func (c *Config) Paths() []string

Paths returns the paths to the configuration files merged from lower index to higher index

func (*Config) Unmarshal added in v1.5.0

func (c *Config) Unmarshal(out interface{}) error

Unmarshal returns the current configuration. Unmarshal returns an error if the configuration cannot be unmarshalled.

type Option added in v1.1.5

type Option = func(s *Config)

func WithDefault added in v1.5.0

func WithDefault(cfg interface{}) Option

WithDefault sets the default config to be used when no values are provided.

func WithEnvironmentVariables added in v1.5.0

func WithEnvironmentVariables(ev map[string][]string) Option

func WithFlags added in v1.5.0

func WithFlags(flags map[string][]*pflag.Flag) Option

func WithPaths added in v1.5.0

func WithPaths(path ...string) Option

WithPaths sets paths to configuration files to be loaded paths to configuration files merged from [0] to [N] e.g. file at index 1 overrides index 0, index 2 overrides index 1 and 0, etc.

func WithValues added in v1.5.0

func WithValues(values map[string]any) Option

WithValues sets values to be injected into the config, taking precedence over all other options.

Directories

Path Synopsis
gen

Jump to

Keyboard shortcuts

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