util

package
v0.0.0-...-5ee8180 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2021 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthConfig

type AuthConfig struct {
	SigningKey string `mapstructure:"signingKey"`
	ExpiryTime int    `mapstructure:"expiryTime"`
	Client     string `mapstructure:"client"`
}

type AuthService

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

AuthService implements AuthService interface

func NewAuthService

func NewAuthService(config Config) (*AuthService, error)

NewAuthService create a new go auth service

func (*AuthService) Allow

func (s *AuthService) Allow(header http.Header) bool

func (*AuthService) GenerateJWT

func (s *AuthService) GenerateJWT() (string, error)

func (*AuthService) GetDefaultError

func (s *AuthService) GetDefaultError() (error, int)

type Config

type Config struct {
	DB            DBConfig            `mapstructure:"db"`
	MessageBroker MessageBrokerConfig `mapstructure:"message-broker"`
	Limiter       LimiterConfig       `mapstructure:"limiter"`
	Auth          AuthConfig          `mapstructure:"auth"`
}

func LoadConfig

func LoadConfig(path string, name string) (config Config, err error)

LoadConfig reads configuration from file or environment variables.

type DBConfig

type DBConfig struct {
	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Name     string `mapstructure:"name"`
	User     string `mapstructure:"user"`
	Password string `mapstructure:"password"`
	SSLMode  string `mapstructure:"sslmode"`
}

type LimiterConfig

type LimiterConfig struct {
	MaxEventsPerSec int `mapstructure:"maxEventsPerSec"`
	MaxBurstSize    int `mapstructure:"maxBurstSize"`
}

type LimiterService

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

LimiterService implements LimiterService interface

func NewLimiterService

func NewLimiterService(config Config) (*LimiterService, error)

NewLimiterService create a new go rate limiter service

func (*LimiterService) Allow

func (s *LimiterService) Allow() bool

func (*LimiterService) GetDefaultError

func (s *LimiterService) GetDefaultError() (error, int)

type MessageBrokerConfig

type MessageBrokerConfig struct {
	Host     string                 `mapstructure:"host"`
	Port     string                 `mapstructure:"port"`
	User     string                 `mapstructure:"user"`
	Password string                 `mapstructure:"password"`
	Queue    map[string]QueueConfig `mapstructure:"queue"`
}

type MessageBrokerService

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

MessageBrokerService implements MessageBrokerService interface

func NewRabbitMQService

func NewRabbitMQService(config Config, metric MetricProvider) (*MessageBrokerService, error)

NewRabbitService create a new rabbit mq service

func (*MessageBrokerService) Consume

func (s *MessageBrokerService) Consume(queue string, stopChan chan bool, process func([]byte) error) error

func (*MessageBrokerService) Publish

func (s *MessageBrokerService) Publish(queue string, body interface{}) error

type MetricProvider

type MetricProvider interface {
	SaveHistogram(handler, method, statusCode string, duration float64)
}

type MetricService

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

MetricService implements MetricService interface

func NewPrometheusService

func NewPrometheusService() (*MetricService, error)

NewPrometheusService create a new prometheus service

func (*MetricService) Handler

func (s *MetricService) Handler() http.Handler

func (*MetricService) SaveHistogram

func (s *MetricService) SaveHistogram(handler, method, statusCode string, duration float64)

type QueueConfig

type QueueConfig struct {
	Durable      bool `mapstructure:"durable"`
	DeleteUnused bool `mapstructure:"delete-unused"`
	Exclusive    bool `mapstructure:"exclusive"`
	NoWait       bool `mapstructure:"no-wait"`
}

Jump to

Keyboard shortcuts

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