config

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Log is the configuration for the logger.
	//
	// The logger configuration contains the log level and the log format.
	Log LogConfig `yaml:"log"`

	// GRPC is the configuration of the gRPC server.
	//
	// The gRPC server configuration contains the network, address, and maximum message size.
	GRPC GRPCConfig `yaml:"grpc"`

	// Webhooks is the configuration for the webhooks.
	//
	// The webhook configuration contains the unique identifier and the target URL of the webhook.
	Webhooks Webhooks `yaml:"webhooks"`
}

Config represents the configuration of the application.

It contains the configuration for the logger and the gRPC server.

func New

func New(path string) (Config, error)

New reads the configuration from a YAML file and returns an instance of Config. It takes the path to the YAML file as a parameter and returns the parsed configuration or an error if there was an issue reading or parsing the file.

The path parameter is a string that represents the path to the YAML file. It returns a Config instance and an error.

type GRPCConfig

type GRPCConfig struct {
	// Network is the network protocol to use for the gRPC server.
	// It is the transport protocol that the server will use to communicate with clients.
	// The possible values are:
	// - "tcp" for IPv4 or IPv6
	// - "udp" for connectionless communication
	Network string `yaml:"network"`

	// Host is the host address to use for the gRPC server.
	// It can be an IP address or a hostname.
	Host string `yaml:"host"`

	// Port is the port number to use for the gRPC server.
	// It is the port number where the gRPC server will listen for incoming connections.
	Port string `yaml:"port"`
}

GRPCConfig represents the configuration of the gRPC server.

It contains the network protocol, host address, and port number to use for the gRPC server.

func (GRPCConfig) Addr

func (c GRPCConfig) Addr() string

Addr returns the address of the gRPC server as a string.

The address is formed by joining the Host and Port fields of the GRPCConfig using the net.JoinHostPort function. The resulting string has the format "host:port".

Parameters: - None

Returns: - string: The address of the gRPC server in the format "host:port".

type LogConfig

type LogConfig struct {
	// Level is the log level.
	//
	// The log level determines the severity of the log messages that will be logged.
	// The possible values are:
	// - "debug" for low-level debugging information
	// - "info" for informational messages
	// - "warn" for warnings or potential issues
	// - "error" for errors that should be addressed
	// - "fatal" for critical errors that cause the application to exit
	Level string `yaml:"level"`
}

LogConfig represents the configuration for the logger.

It contains the log level.

type WebhookConfig

type WebhookConfig struct {
	// ID is the unique identifier for the webhook.
	//
	// The ID is a string that uniquely identifies the webhook.
	// It is used to distinguish between different webhooks.
	ID uuid.UUID `yaml:"id"`

	// Target is the target URL of the webhook.
	//
	// The target URL is the URL that will be notified when an event is triggered.
	// It should be a valid URL that the webhook can reach.
	//
	// Example: "https://example.com/webhook"
	Target string `yaml:"target"`
}

WebhookConfig represents the configuration for the webhook.

It contains the unique identifier and the target URL of the webhook.

type Webhooks

type Webhooks []WebhookConfig

Webhooks is a slice of WebhookConfig.

func (Webhooks) AsMap

func (w Webhooks) AsMap() map[uuid.UUID]string

AsMap converts the slice of WebhookConfig into a map.

The function takes the slice of WebhookConfig as input and returns a map with the ID of the WebhookConfig as the key and the target URL as the value. The map is created with preallocated capacity to avoid resizing during iteration.

Returns: - A map[uuid.UUID]string containing the converted data.

Jump to

Keyboard shortcuts

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