pgleaderchk

package
v0.0.0-...-837eb61 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 8 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 {
	Db   DatabaseConfig `mapstructure:"database"`
	Http HttpConfig     `mapstructure:"httpd"`
	Log  LogConfig      `mapstructure:"log"`
}

func ConfigFromViper

func ConfigFromViper() (*Config, error)

ConfigFromViper returns a Server config from the service's configuration file and the viper CLI arguments.

type DatabaseConfig

type DatabaseConfig struct {
	Hostname string `mapstructure:"hostname" toml:"hostname"`
	Port     int    `mapstructure:"port" toml:"port"`
	Database string `mapstructure:"dbname" toml:"dbname"`
	User     string `mapstructure:"username" toml:"username"`
	Password string `mapstructure:"password" toml:"password"`
	Sslmode  string `mapstructure:"sslmode" toml:"sslmode"`
}

type HttpConfig

type HttpConfig struct {
	Hostname string `mapstructure:"bind" toml:"bind"`
	Port     int    `mapstructure:"port" toml:"port"`
}

type LogConfig

type LogConfig struct {
	Level string `mapstructure:"level" toml:"level"`
}

type Opts

type Opts func(*Server)

func WithDB

func WithDB(hostname string, port int, user string, password string, dbname string, sslmode string) Opts

WithDB allows setting the URI to use from hostname and port

func WithLogLevel

func WithLogLevel(lvl string) Opts

WithLogLevel sets the log level to use.

func WithURI

func WithURI(hostname string, port int) Opts

WithURI allows setting the URI to use from hostname and port

type ResponseMessage

type ResponseMessage struct {
	Status string
	Body   string
}

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server holds the state of an instance of this service

func New

func New(opts ...Opts) *Server

New initializes a *Server from the passed options

func NewFromConfig

func NewFromConfig(cfg *Config) (*Server, error)

NewFromConfig initializes a Server given a Config

func (*Server) Serve

func (s *Server) Serve() error

Serve finalizes the Server setup, and listens for connections. Only returns if something went wrong, with a non-nil error.

Jump to

Keyboard shortcuts

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