praetor

package module
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

README

praetor

praetor integrates go.uber.org/fx with consul.

Build Status codecov.io Go Report Card Apache V2 License Quality Gate Status GitHub release PkgGoDev

Summary

Praetor provides a basic, opinionated way of integrating consul into a go.uber.org/fx application. In particular, it allows for external configuration to drive service registration and discovery. Praetor also binds service registration and discovery to the application lifecycle.

Table of Contents

Code of Conduct

This project and everyone participating in it are governed by the XMiDT Code Of Conduct. By participating, you agree to this Code.

Install

go get -u github.com/xmidt-org/praetor

Contributing

Refer to CONTRIBUTING.md.

Documentation

Overview

Package praetor provides a basic, opinionated way of integrated a consul Client with go.uber.org/fx.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decorate

func Decorate(original api.Config, opts ...Option) (cfg api.Config, err error)

Decorate is an uber/fx decorator that returns a new consul client Config that results from applying any number of options to an existing Config. If no options are supplied, this function returns a clone of the original.

func New

func New(cfg api.Config, opts ...Option) (c *api.Client, err error)

New is the standard constructor for a consul client. It allows for any number of options to tailor the configuration after the api.Config has been unmarshaled or obtained from some external source.

This function may be used directly with fx.Provide as a constructor. More commonly, the Provide function in this package is preferred since it allows simpler annotation.

func Provide

func Provide(external ...Option) fx.Option

Provide gives a very simple, opinionated way of using New within an fx.App. It assumes a global, unnamed api.Config optional dependency and zero or more ClientOptions in a value group named 'consul.options'.

Zero or more options that are external to the enclosing fx.App may be supplied to this provider function. This allows the consul Client to be modified by command-line options, hardcoded values, etc. Any external options supplied to this function take precedence over injected options.

This provider emits a global, unnamed *api.Client.

Types

type Option

type Option func(*api.Config) error

Option is a functional option for tailoring the consul client configuration prior to creating it. Each option can modify the *api.Config prior to it being passed to api.NewClient.

func AsOption

func AsOption[O ~func(*api.Config) error](opts ...O) Option

AsOption bundles one or more functions into a single Option.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient configures the consul client with a custom HTTP client.

Jump to

Keyboard shortcuts

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