cfg

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package cfg dispatches several calculations. It avoids to start a specific program for each calculation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Launch

func Launch(name string, path string) error

Launch launchs a specific calculation. It is a thread blocking method. The parameters required to launch the calculation must be in a file.

Types

type Calculation

type Calculation interface {
	Start() error
}

Calculation is an interface that only contains one method: Start. Every calculation must have a Start method that will launch the calculation. It must be a thread blocking method.

type Cfg

type Cfg struct {
	Types [][]string `toml:"types"`
	Files [][]string `toml:"files"`
}

Cfg is a structure where the types of calculations are stored. It can be instanced through the New method. The length of the Files slice must be equal to the length of the Types files. Each calculation requires a configuration file where the parameters required to run the calculation are stored.

func New

func New(path string) (Cfg, error)

New returns an instance of the Cfg structure. It opens and reads the configuration file where Types and Files are stored. The configuration file must use the TOML format.

func (Cfg) Start

func (c Cfg) Start(log *log.Logger)

Start dispatches and performs the calculations. If several calculations are in the same array (e.g Types: ["x", "y", "z"]), they will be performed in parrallel. In general, one calculation uses one thread. The length of the array must be in accordance with the number of threads used by the calculations and the number of threads available.

It is a thread blocking method. If an error occurs for a specific calculation, the calculation will stop and log the error but the method won't stop.

Jump to

Keyboard shortcuts

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