huner

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2022 License: MIT Imports: 29 Imported by: 0

README

hexa-tuner tune Hexa services.

Install

go get github.com/kamva/hexa-tuner

Used config variables:

// Translator config variables
translate.files (optional) : []string translation files.
translate.fallback.langs (optional,default:en): []string fallback langues

e.g environtment variable list in viper driver of cofig:
TRANSLATE.FILES="fa en"
TRANSLATE.FALLBACK.LANGS="en fa"

Todo:

  • Write Tests
  • Add badges to readme.
  • CI

Documentation

Index

Constants

View Source
const Version = "v1.0.0"

Version is the package current version.

Variables

This section is empty.

Functions

func EnvKeysPrefix

func EnvKeysPrefix() string

func Environment

func Environment(prefix string) string

func GRPCConn

func GRPCConn(o GrpcConnOptions) (*grpc.ClientConn, error)

GRPCConn returns new instance of the gRPC connection with your config to use in client

func GetConfigFilePaths

func GetConfigFilePaths(o ConfigFilePathsOpts) []string

GetConfigFilePaths generates config path as follow: - /etc/{appName}/{configFile.configExtension} - /etc/{appName}/{serviceName.configExtension} - {HomePath}/{configFile.configExtension} - {HomePath}/.env - {HomePath}/.{environment}.env

func MustGRPCConn

func MustGRPCConn(o GrpcConnOptions) *grpc.ClientConn

MustGRPCConn returns new instance of the gRPC connection with your config to use in client or will panic if occurred any error.

func NewFaktoryJobsDriver

func NewFaktoryJobsDriver(propagator hexa.ContextPropagator, poolSize int) (hjob.Jobs, error)

NewFaktoryJobsDriver generate new faktory driver for hexa jobs.

func NewFaktoryWorkersDriver

func NewFaktoryWorkersDriver(p hexa.ContextPropagator, concurrency int) (hjob.Worker, error)

NewFaktoryWorkersDriver generate new faktory driver for the hexa worker.

func NewTranslator

func NewTranslator(pathPrefix string, cfg TranslateOpts) hexa.Translator

return new translator service.

func NewViperConfigDriver

func NewViperConfigDriver(envPrefix string, files []string) (hexa.Config, error)

NewViperConfigDriver returns new instance of the viper driver for hexa config

func TuneGRPCServer

func TuneGRPCServer(cfg GRPCConfigs, o GRPCServerTunerOptions) (*grpc.Server, error)

TuneGRPCServer returns new instance of the tuned gRPC Server to server requests to services

Types

type BaseServiceContainer

type BaseServiceContainer interface {
	SetConfig(config hexa.Config)
	SetLogger(logger hlog.Logger)
	SetTranslator(translator hexa.Translator)
	SetProbeServer(server probe.Server)
	SetHealthReporter(reporter hexa.HealthReporter)
	SetJobs(jobs hjob.Jobs)
	SetEmitter(emitter hevent.Emitter)
	SetArranger(arranger arranger.Arranger)
	SetDLM(dlm hexa.DLM)
	SetOpenTelemetry(otlm htel.OpenTelemetry)

	Config() hexa.Config
	Logger() hlog.Logger
	Translator() hexa.Translator
	ProbeServer() probe.Server
	HealthReporter() hexa.HealthReporter
	Jobs() hjob.Jobs
	Emitter() hevent.Emitter
	Arranger() arranger.Arranger
	DLM() hexa.DLM
	OpenTelemetry() htel.OpenTelemetry
}

BaseServiceContainer is the base service container to use in each microservice.

func NewBaseServiceContainer

func NewBaseServiceContainer() BaseServiceContainer

NewBaseServiceContainer returns new instance of the BaseServiceContainer.

type ConfigFilePathsOpts

type ConfigFilePathsOpts struct {
	AppName       string // e.g., senna
	ServiceName   string // e.g., order
	HomePath      string // e.g., /home/mehran/senna/order
	FileName      string // e.g., config
	FileExtension string // e.g., json or yaml
	Environment   string // (optional) e.g., staging
}

type GRPCConfigs

type GRPCConfigs struct {
	Debug        bool
	LogVerbosity int `json:"log_verbosity" yaml:"log_verbosity"`
}

type GRPCServerTunerOptions

type GRPCServerTunerOptions struct {
	ContextPropagator hexa.ContextPropagator
	Logger            hlog.Logger
	Translator        hexa.Translator
	MetricsOpts       hrpc.MetricsOptions
	TracingOpts       []otelgrpc.Option
}

GRPCServerTunerOptions contains options needed to tune a gRPC server

type GrpcConnOptions

type GrpcConnOptions struct {
	Addr        string
	Propagator  hexa.ContextPropagator
	TracingOpts []otelgrpc.Option
}

func (*GrpcConnOptions) WithAddr

func (o *GrpcConnOptions) WithAddr(addr string) GrpcConnOptions

WithAddr returns a new grpc config with the new address.

type TranslateOpts

type TranslateOpts struct {
	Files         []string
	FallbackLangs []string
}

type TunerOptions

type TunerOptions struct {
	IsDebug bool
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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