mortar

package
v0.0.0-...-109f6fb Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2022 License: MIT Imports: 23 Imported by: 0

README

/app/mortar

Code in this directory is related to Mortar and uber-fx

  • Mortar Providers invocations.
  • Builders
  • Your constructors wrapped as fx.Option
  • Tracing/Monitoring/Logger implicit configurations

HTTP

Constructors, options, interceptors and everything related to HTTP can be found in http.go

Monitoring

This template is ready to work with a Prometheus service. You need to configure it to expect a metric on this service default internal REST port.

mortar:
  # Web server related configuration
  server:
    ...
    rest:
      ...
      internal:
        port: 5382

By default it's :5382/metrics

Constructors, options and everything else can be found in metrics.go.

Tracing

This template is assuming you will use Jaeger service.

In order for the bundled client to connect your Jaeger service you need to export some ENVIRONMENT variables.

export JAEGER_AGENT_HOST = localhost
export JAEGER_AGENT_PORT = 6831
export JAEGER_SAMPLER_TYPE = const
export JAEGER_SAMPLER_PARAM = 1

They are included in the makefile, when you execute make run they are exported.

Constructors, options and everything else can be found in tracing.go.

Logger

This template is using the zerolog library. Zerolog can be configured to output in JSON format which is useful in production or the Console format which is useful for debug/local environments. By default it is configured to use the Console format. You can export SERVER_LOGGER_CONSOLE=false environment variable to disable this behavior in production or change the config.yml file.

Constructors, options and everything else can be found in logger.go.

Config

This template is using the viper library.

Constructors, options and everything else can be found in config.go.

Authentication

This template doesn't enforce any Authentication. However there is a sample code showing how you can parse a JWT if found. Default usage can be found in ../validations/auth.go

Constructors, options and everything else can be found in auth.go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthFxOptions

func AuthFxOptions() fx.Option

func HttpClientFxOptions

func HttpClientFxOptions() fx.Option

func HttpServerFxOptions

func HttpServerFxOptions() fx.Option

func InternalHttpHandlersFxOptions

func InternalHttpHandlersFxOptions() fx.Option

These will help you to debug/profile or understand the internals of your service

func JaegerBuilder

func JaegerBuilder(lc fx.Lifecycle, config cfg.Config, logger log.Logger) (opentracing.Tracer, error)

JaegerBuilder constructor assumes you have JAEGER environment variables set

https://github.com/jaegertracing/jaeger-client-go#environment-variables

Once built it will register Lifecycle hooks (connect on start, close on stop)

func LoggerFxOption

func LoggerFxOption() fx.Option

func PrometheusBuilder

func PrometheusBuilder(cfg cfg.Config) monitor.Builder

PrometheusBuilder returns a monitor.Builder that is implemented by Prometheus

func PrometheusFxOption

func PrometheusFxOption() fx.Option

PrometheusFxOption registers prometheus

func ServiceAPIsAndOtherDependenciesFxOption

func ServiceAPIsAndOtherDependenciesFxOption() fx.Option

func TracerFxOption

func TracerFxOption() fx.Option

func ViperFxOption

func ViperFxOption(configFilePath string, additionalFilePaths ...string) fx.Option

Types

This section is empty.

Jump to

Keyboard shortcuts

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