config

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AMQPConfig

type AMQPConfig struct {
	// Host is the host of the queue
	Host string `yaml:"host,omitempty" json:"host,omitempty"`

	// Port is the port of the queue
	Port int `yaml:"port,omitempty" json:"port,omitempty"`

	// Username is the username of the queue
	Username string `yaml:"username,omitempty" json:"username,omitempty"`

	// Password is the password of the queue
	Password string `yaml:"password,omitempty" json:"password,omitempty"`
}

AMQPConfig is the main configuration information needed to connect to an AMQP provider

type Config

type Config struct {
	// Providers is a list of sources that will be connected to
	Providers []*ProviderConfig `yaml:"providers" json:"providers"`

	// Queues is a list of queues that will be consumed
	Queues []*QueueConfig `yaml:"queues" json:"queues"`

	// Debug is a flag that enables debug logging
	Debug bool `yaml:"debug" json:"debug"`

	// Metrics is the configuration for the metrics endpoint
	Metrics *MetricsConfig `yaml:"metrics" json:"metrics"`

	// Log is the format of the log
	Log string `yaml:"log,omitempty" json:"log"`

	// Databases is the configuration for the database connections
	Databases []*DatabaseConfig `yaml:"databases" json:"databases"`
}

Config is the main configuration struct

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the configuration from a file which can be either YAML or JSON.

func (*Config) ValidateAll

func (c *Config) ValidateAll() error

ValidateAll validates the configuration

type DatabaseConfig added in v0.3.3

type DatabaseConfig struct {
	// Name is the name of the database
	Name string `yaml:"name" json:"name"`

	// Type is the type of the database
	Type string `yaml:"type" json:"type"`

	// ConnectionString is the connection string for the database
	ConnectionString string `yaml:"connection-string" json:"connection-string"`

	// Retry is the amount of times the connection should be retried
	Retry int `yaml:"retry,omitempty" json:"retry,omitempty"`

	// Database is the database name for the database
	Database string `yaml:"database,omitempty" json:"database,omitempty"`
}

DatabaseConfig is the configuration for the database connections

type DatabaseRouteConfig added in v0.3.3

type DatabaseRouteConfig struct {
	// Name is the name of the database route
	Name string `yaml:"name" json:"name"`

	// Provider is the name of the provider database
	Provider string `yaml:"provider" json:"provider"`

	// Table is the name of the table in a SQL database
	Table string `yaml:"table,omitempty" json:"table,omitempty"`

	// Collection is the name of the collection in a NoSQL database
	Collection string `yaml:"collection,omitempty" json:"collection,omitempty"`

	// Mapping is the mapping of the message to the database
	Mapping map[string]string `yaml:"mapping" json:"mapping"`
}

DatabaseRouteConfig is the main configuration information needed to store a message in a database

type KafkaConfig

type KafkaConfig struct {
	// Brokers is a list of brokers that will be consumed
	Brokers []string `yaml:"brokers,omitempty" json:"brokers,omitempty"`

	// Topic is a list of topics that will be consumed
	Topic string `yaml:"topic,omitempty" json:"topic,omitempty"`

	// Group is the consumer group that will be used
	Group string `yaml:"group,omitempty" json:"group,omitempty"`
}

KafkaConfig is the main configuration information needed to connect to a Kafka provider

type MetricsConfig added in v0.3.1

type MetricsConfig struct {
	// Enabled is a flag that enables the metrics endpoint
	Enabled bool `yaml:"enabled" json:"enabled"`

	// Port is the port that the metrics endpoint will listen on
	Port int `yaml:"port,omitempty" json:"port,omitempty"`

	// Path is the path that the metrics endpoint will listen on
	Path string `yaml:"path,omitempty" json:"path,omitempty"`

	// ThresholdStatus is the minimum status code that will increase failure count, defaults to 500
	ThresholdStatus int `yaml:"threshold_status,omitempty" json:"threshold_status,omitempty"`
}

MetricsConfig is the configuration for the metrics endpoint

type ProviderConfig

type ProviderConfig struct {
	// Name is the name of the provider
	Name string `yaml:"name" json:"name"`

	// Type is the type of the provider, such as "amqp" or "kafka"
	Type string `yaml:"type" json:"type"`

	// Retry is the number of times to retry connecting to the provider
	Retry int `yaml:"retry,omitempty" json:"retry,omitempty"`

	// AMQPConfig is the configuration for the AMQP provider
	AMQPConfig *AMQPConfig `yaml:"amqp-config,omitempty" json:"amqp-config,omitempty"`

	// KafkaConfig is the configuration for the Kafka provider
	KafkaConfig *KafkaConfig `yaml:"kafka-config,omitempty" json:"kafka-config,omitempty"`

	// StompMQConfig is the configuration for the ActiveMQ provider
	StompMQConfig *StompConfig `yaml:"stomp-config,omitempty" json:"stomp-config,omitempty"`
}

ProviderConfig is the main configuration information needed to connect to a provider

type QueueConfig

type QueueConfig struct {
	// Name is the name of the queue
	Name string `yaml:"name" json:"name"`

	// Provider is the provider that will be used to consume the queue
	Provider string `yaml:"provider" json:"provider"`

	// Retry is the retry configuration for the queue
	Retry *RetryConfig `yaml:"retry,omitempty" json:"retry,omitempty"`

	// Routes is the list of routes that will be used to send the messages
	Routes []*RouteConfig `yaml:"routes" json:"routes"`

	// DatabaseRoutes is the list of databases that will be used to store the messages
	DatabaseRoutes []*DatabaseRouteConfig `yaml:"database-routes,omitempty" json:"database-routes,omitempty"`
}

QueueConfig is the main configuration information needed to consume a queue

type RetryConfig

type RetryConfig struct {
	// Enabled is the flag that indicates if the retry is enabled, defaults to false
	Enabled bool `yaml:"enabled,omitempty" json:"enabled,omitempty"`

	// MaxRetries is the maximum number of retries for the queue
	MaxRetries int `yaml:"max_retries" json:"max_retries"`

	// Strategy is the retry strategy for the queue, defaults to "fixed"
	Strategy string `yaml:"strategy,omitempty" json:"strategy,omitempty"`

	// Interval is the interval between retries
	Interval time.Duration `yaml:"interval,omitempty" json:"interval,omitempty"`

	// ThresholdStatus is the minimum status code that will trigger a retry, defaults to 500
	ThresholdStatus int `yaml:"threshold_status,omitempty" json:"threshold_status,omitempty"`
}

RetryConfig is the main configuration information needed to retry a message

type RouteConfig

type RouteConfig struct {
	// Name is the name of the route
	Name string `yaml:"name" json:"name"`

	// URL is the URL of the service
	URL string `yaml:"url" json:"url"`

	// Method is the HTTP method of the request, defaults to "POST"
	Method string `yaml:"method,omitempty" json:"method,omitempty"`

	// Type is the type of the request, defaults to "REST"
	Type string `yaml:"type,omitempty" json:"type,omitempty"`

	// Headers is the list of headers that will be sent with the request
	Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`

	// Body is the body of the request
	Body map[string]interface{} `yaml:"body,omitempty" json:"body,omitempty"`

	// Query is the query string of the request
	Query map[string]string `yaml:"query,omitempty" json:"query,omitempty"`

	// Timeout is the timeout of the request, defaults to 10 seconds
	Timeout time.Duration `yaml:"timeout,omitempty" json:"timeout,omitempty"`
}

RouteConfig is the main configuration information needed to send a message to a service

type StompConfig added in v0.2.0

type StompConfig struct {
	// Host is the host of the queue
	Host string `yaml:"host,omitempty" json:"host,omitempty"`

	// Port is the port of the queue
	Port int `yaml:"port,omitempty" json:"port,omitempty"`

	// Username is the username of the queue
	Username string `yaml:"username,omitempty" json:"username,omitempty"`

	// Password is the password of the queue
	Password string `yaml:"password,omitempty" json:"password,omitempty"`
}

Jump to

Keyboard shortcuts

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