config

package
v0.0.0-...-547d394 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	DefaultSessionExpireTime            = 24 * time.Hour    // 24 hours
	DefaultSessionCheckInterval         = 30 * time.Minute  // 30 minute
	DefaultEngineClientTimeout          = 120 * time.Second // 120s
	DefaultInterTimeout                 = 5 * time.Second   // 5s
	DefaultBrokerIntraServerHost        = "127.0.0.1"       // default use localhost for safety
	DefaultLogLevel                     = "info"
	DefaultEngineProtocol               = "http"
	DefaultExchangeJobInfoRetryTimes    = 3
	DefaultExchangeJobInfoRetryInterval = 200 * time.Millisecond
	DefaultEngineClientMode             = "GRPC"
)
View Source
const (
	StorageTypeSQLite   = "sqlite"
	StorageTypeMySQL    = "mysql"
	StorageTypePostgres = "postgres"
)
View Source
const (
	NoTLS     string = "notls"
	TLS       string = "tls"
	MutualTLS string = "mtls"
)

Variables

This section is empty.

Functions

func LoadTLSConfig

func LoadTLSConfig(mode, cacertPath, certPath, keyPath string) (*tls.Config, error)

Types

type Config

type Config struct {
	IntraServer  ServerConfig  `yaml:"intra_server"`
	InterServer  ServerConfig  `yaml:"inter_server"`
	InterTimeout time.Duration `yaml:"inter_timeout"`
	// used in engine callback
	IntraHost string `yaml:"intra_host"`
	LogLevel  string `yaml:"log_level"`
	// self party code
	PartyCode      string `yaml:"party_code"`
	PrivateKeyPath string `yaml:"private_key_path"`
	InterHost      string `yaml:"inter_host"`
	// base64 encoded PEM-encoded private key
	PrivateKeyData     string                 `yaml:"private_key_data"`
	PartyInfoFile      string                 `yaml:"party_info_file"`
	Engine             EngineConfig           `yaml:"engine"`
	Storage            StorageConf            `yaml:"storage"`
	SecurityCompromise SecurityCompromiseConf `yaml:"security_compromise"`
	Discovery          DiscoveryConf          `yaml:"discovery"`
	// cache
	SessionExpireTime    time.Duration `yaml:"session_expire_time"`
	SessionCheckInterval time.Duration `yaml:"session_expire_check_time"`
	// PersistSession       bool          `yaml:"persist_session"`
	// streaming
	Batched bool `yaml:"batched"`
	// exchange job info
	ExchangeJobInfoRetryTimes    int           `yaml:"exchange_job_info_retry_times"`
	ExchangeJobInfoRetryInterval time.Duration `yaml:"exchange_job_info_retry_interval"`

	AuthorizedWritableParties []string `yaml:"authorized_writable_parties"`
}

func NewConfig

func NewConfig(configPath string) (*Config, error)

NewConfig construsts Config from YAML file

type ConsulApiConf

type ConsulApiConf struct {
	Address    string   `yaml:"address"`
	Token      string   `yaml:"token"`
	TLS        *TLSConf `yaml:"tls"`
	Datacenter string   `yaml:"datacenter"`
}

type DiscoveryConf

type DiscoveryConf struct {
	// supported discovery types: "file", "kuscia"
	Type   string          `yaml:"type"`
	File   string          `yaml:"file"`
	Consul *ConsulApiConf  `yaml:"consul"`
	Kuscia *KusciaDiscConf `yaml:"kuscia"`
}

type EngineConfig

type EngineConfig struct {
	ClientMode    string        `yaml:"mode"`
	ClientTimeout time.Duration `yaml:"timeout"`
	Protocol      string        `yaml:"protocol"`
	TLSCfg        TLSConf       `yaml:"tls_cfg"`
	ContentType   string        `yaml:"content_type"`
	// supported schedulers: "kuscia" or "naive"
	Scheduler string `yaml:"scheduler"`
	// Uris valid when scheduler is empty or "naive"
	Uris []EngineUri `yaml:"uris"`
	// KusciaSchedulerOption valid only when scheduler is "kuscia"
	KusciaSchedulerOption *KusciaSchedulerConf `yaml:"kuscia_scheduler"`
}

type EngineUri

type EngineUri struct {
	ForPeer string `yaml:"for_peer"`
	ForSelf string `yaml:"for_self"`
}

type KusciaApiConf

type KusciaApiConf struct {
	Endpoint string `yaml:"endpoint"`
	// supported tls mode: "NOTLS", "TLS", "MTLS"
	// - Token is needed if tls_mode == TLS or tls_mode == MTLS
	TLSMode string `yaml:"tls_mode"`
	Cert    string `yaml:"cert"`
	Key     string `yaml:"key"`
	CaCert  string `yaml:"cacert"`
	Token   string `yaml:"token"`
}

type KusciaDiscConf

type KusciaDiscConf struct {
	KusciaApiConf `yaml:",inline"`
	ClusterDefine string `yaml:"cluster_define"`
}

type KusciaSchedulerConf

type KusciaSchedulerConf struct {
	KusciaApiConf `yaml:",inline"`

	MaxPollTimes int           `yaml:"max_poll_times"`
	PollInterval time.Duration `yaml:"poll_interval"`
	MaxWaitTime  time.Duration `yaml:"max_wait_time"`
	AppImage     string        `yaml:"app_image"`

	// default value is false, set true for debugging purpose
	KeepJobAliveForDebug bool `yaml:"keep_job_alive_for_debug"`
}

type SecurityCompromiseConf

type SecurityCompromiseConf struct {
	GroupByThreshold uint64 `yaml:"group_by_threshold"`
	RevealGroupMark  bool   `yaml:"reveal_group_mark"`
	RevealGroupCount bool   `yaml:"reveal_group_count"`
}

type ServerConfig

type ServerConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Protocol string `yaml:"protocol"`
	CertFile string `yaml:"cert_file"`
	KeyFile  string `yaml:"key_file"`
}

type StorageConf

type StorageConf struct {
	Type            string        `yaml:"type"`
	ConnStr         string        `yaml:"conn_str"`
	MaxIdleConns    int           `yaml:"max_idle_conns"`
	MaxOpenConns    int           `yaml:"max_open_conns"`
	ConnMaxIdleTime time.Duration `yaml:"conn_max_idle_time"`
	ConnMaxLifetime time.Duration `yaml:"conn_max_lifetime"`
}

type TLSConf

type TLSConf struct {
	Mode       string `yaml:"mode"`
	CertPath   string `yaml:"cert"`
	KeyPath    string `yaml:"key"`
	CACertPath string `yaml:"cacert"`
}

Jump to

Keyboard shortcuts

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