config

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ActiveAresNameSpace is current namespace of a list of Ares Supported in current service
	ActiveAresNameSpace string

	// ActiveJobNameSpace is current namespace of a list of jobs Supported in current service
	ActiveJobNameSpace string

	// ConfigRootPath is the root path of config
	ConfigRootPath string = "config"

	// ConfigFile is the file path of config file
	ConfigFile string

	// Module configures an HTTP server.
	Module = fx.Options(
		fx.Provide(
			NewServiceConfig,
		),
	)

	// SinkIsAresDB is a flag. It is true if sink is aresDB
	SinkIsAresDB = false

	// EtcdCfgEvent is used to detect etcd cluster changes
	EtcdCfgEvent = make(chan int, 1)
)

Functions

This section is empty.

Types

type AresNSConfig

type AresNSConfig struct {
	AresNameSpaces map[string][]string   `yaml:"namespaces"`
	AresClusters   map[string]SinkConfig `yaml:"clusters"`
}

AresNSConfig defines the mapping b/w ares namespace and its clusters

type ControllerConfig

type ControllerConfig struct {
	// Enable defines whether to enable aresDB controll or not
	Enable bool `yaml:"enable" default:"false"`
	// Address is aresDB controller address
	Address string `yaml:"address" default:"localhost:5436"`
	// Timeout is request sent to aresDB controller timeout in seconds
	Timeout int `yaml:"timeout" default:"30"`
	// RefreshInterval is the interval to sync up with aresDB controller in minutes
	RefreshInterval int `yaml:"refreshInterval" default:"10"`
	// ServiceName is aresDB controller name
	ServiceName string `yaml:"serviceName" default:"ares-controller"`
}

ControllerConfig defines aresDB controller configuration

type EtcdClusterConfig

type EtcdClusterConfig struct {
	EtcdCluster etcd.ClusterConfig `yaml:",inline"`
	UNS         string             `yaml:"uns"`
}

type EtcdConfig

type EtcdConfig struct {
	*sync.Mutex

	EtcdConfig etcd.Configuration `yaml:",inline"`
}

type HeartBeatConfig

type HeartBeatConfig struct {
	Enabled       bool `yaml:"enabled"`
	Timeout       int  `yaml:"timeout"`
	Interval      int  `yaml:"interval"`
	CheckInterval int  `yaml:"checkInterval"`
}

HeartBeatConfig represents heartbeat config

type JobNSConfig

type JobNSConfig struct {
	Jobs map[string][]string `yaml:"namespaces"`
}

JobNSConfig defines the mapping b/w job namespace and its clusters

type KafkaProducerConfig

type KafkaProducerConfig struct {
	// Brokers defines a list of broker addresses separated by comma
	Brokers string `yaml:"brokers" json:"brokers"`
	// RetryMax is the max number of times to retry sending a message (default 3).
	RetryMax int `yaml:"retryMax" json:"retryMax"`
	// TimeoutInMSec is the max duration the broker will wait
	// the receipt of the number of RequiredAcks (defaults to 10 seconds)
	TimeoutInSec int `yaml:"timeoutInSec" json:"timeoutInSec"`
	// SchemaRefreshInterval is the interval in seconds for the connector to
	// fetch and refresh schema from ares
	// if <= 0, will use default
	SchemaRefreshInterval int `yaml:"schemaRefreshInterval" json:"schemaRefreshInterval"`
}

KafkaProducerConfig represents Kafka producer configuration

type Params

type Params struct {
	fx.In

	Environment utils.EnvironmentContext
	Logger      *zap.Logger
	Scope       tally.Scope
	Config      cfgfx.Provider
}

Params defines the base objects for a service.

type Result

type Result struct {
	fx.Out

	ServiceConfig ServiceConfig
}

Result defines the objects that the config module provides.

func NewServiceConfig

func NewServiceConfig(p Params) (Result, error)

NewServiceConfig constructs ServiceConfig.

type ServiceConfig

type ServiceConfig struct {
	Environment utils.EnvironmentContext
	Logger      *zap.Logger
	Scope       tally.Scope
	Config      cfgfx.Provider

	Service            string                `yaml:"service.name"`
	BackendPort        int                   `yaml:"rest.http.address"`
	AresNSConfig       AresNSConfig          `yaml:"ares"`
	JobNSConfig        JobNSConfig           `yaml:"jobs"`
	ActiveAresClusters map[string]SinkConfig `yaml:"-"`
	ActiveJobs         []string              `yaml:"-"`
	ControllerConfig   *ControllerConfig     `yaml:"controller"`
	ZooKeeperConfig    ZooKeeperConfig       `yaml:"zookeeper"`
	EtcdConfig         EtcdConfig            `yaml:"etcd"`
	EtcdClustersConfig []EtcdClusterConfig   `yaml:"etcd.etcdClusters"`
	HeartbeatConfig    *HeartBeatConfig      `yaml:"heartbeat"`
}

ServiceConfig defines the service configuration.

type SinkConfig

type SinkConfig struct {
	// SinkMode defines the subscriber sink mode
	SinkModeStr string `yaml:"sinkMode" json:"sinkMode"`
	// AresDBConnectorConfig defines aresDB client config
	AresDBConnectorConfig client.ConnectorConfig `yaml:"aresDB" json:"aresDB"`
	// KafkaProducerConfig defines Kafka producer config
	KafkaProducerConfig KafkaProducerConfig `yaml:"kafkaProducer" json:"kafkaProducer"`
}

SinkConfig wraps sink configurations

func (SinkConfig) GetSinkMode

func (s SinkConfig) GetSinkMode() SinkMode

type SinkMode

type SinkMode int

SinkMode defines the subscriber sink mode

const (
	Sink_Undefined SinkMode = iota
	Sink_AresDB
	Sink_Kafka
)

type ZooKeeperConfig

type ZooKeeperConfig struct {
	// Server defines zookeeper server addresses
	Server                   string        `yaml:"server"`
	SessionTimeoutSeconds    time.Duration `yaml:"sessionTimeoutSeconds" default:"60"`
	ConnectionTimeoutSeconds time.Duration `yaml:"connectionTimeoutSeconds" default:"15"`
	BaseSleepTimeSeconds     time.Duration `yaml:"exponentialBackoffRetryPolicy.baseSleepTimeSeconds" default:"1"`
	MaxRetries               int           `yaml:"exponentialBackoffRetryPolicy.maxRetries" default:"3"`
	MaxSleepSeconds          time.Duration `yaml:"exponentialBackoffRetryPolicy.maxSleepSeconds" default:"15"`
}

ZooKeeperConfig defines the ZooKeeper client configuration

Jump to

Keyboard shortcuts

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