patron

package module
v0.73.2 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2022 License: Apache-2.0 Imports: 20 Imported by: 0

README

patron CI Coverage Status Go Report Card GoDoc GitHub release

Patron is a framework for creating microservices, originally created by Sotiris Mantzaris (https://github.com/mantzas). This fork is maintained by Beat Engineering (https://thebeat.co)

Patron is french for template or pattern, but it means also boss which we found out later (no pun intended).

The entry point of the framework is the Service. The Service uses Components to handle the processing of sync and async requests. The Service starts by default an HTTP Component which hosts the /debug, /alive, /ready and /metrics endpoints. Any other endpoints will be added to the default HTTP Component as Routes. Alongside Routes one can specify middleware functions to be applied ordered to all routes as MiddlewareFunc. The service sets up by default logging with zerolog, tracing and metrics with Jaeger and prometheus.

Patron provides abstractions for the following functionality of the framework:

  • service, which orchestrates everything
  • components and processors, which provide an abstraction of adding processing functionality to the service
    • asynchronous message processing (RabbitMQ, Kafka, AWS SQS)
    • synchronous processing (HTTP)
    • gRPC support
  • metrics and tracing
  • logging

Patron provides the same defaults for making the usage as simple as possible. Patron needs Go 1.17 as a minimum.

Table of Contents

Documentation

Overview

Package patron framework

Patron is a framework for creating microservices.

Patron is french for template or pattern, but it means also boss which we found out later (no pun intended).

The entry point of the framework is the Service. The Service uses Components to handle the processing of sync and async requests. The Service can set up as many Components it wants, even multiple HTTP components provided the port does not collide. The Service starts by default an HTTP component which hosts the debug, alive, ready and metric endpoints. Any other endpoints will be added to the default HTTP Component as Routes. The service set's up by default logging with zerolog, tracing and metrics with jaeger and prometheus.

Patron provides abstractions for the following functionality of the framework:

  • service, which orchestrates everything
  • components and processors, which provide an abstraction of adding processing functionality to the service
  • asynchronous message processing (RabbitMQ, Kafka)
  • synchronous processing (HTTP)
  • metrics and tracing
  • logging
  • configuration management

Patron provides same defaults for making the usage as simple as possible. For more details please check out the GitHub repository https://github.com/beatlabs/patron.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder added in v0.32.0

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

Builder gathers all required properties to construct a Patron service.

func New

func New(name, version string, options ...Option) (*Builder, error)

New creates a builder with functional options.

func (*Builder) Run added in v0.32.0

func (b *Builder) Run(ctx context.Context) error

Run starts up all service components and monitors for errors. If a component returns an error the service is responsible for shutting down all components and terminate itself.

func (*Builder) WithAliveCheck deprecated added in v0.32.0

func (b *Builder) WithAliveCheck(acf patronhttp.AliveCheckFunc) *Builder

WithAliveCheck overrides the default liveness check of the default HTTP component.

Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.

func (*Builder) WithComponents added in v0.32.0

func (b *Builder) WithComponents(cc ...Component) *Builder

WithComponents adds custom components to the Patron service.

func (*Builder) WithMiddlewares deprecated added in v0.32.0

func (b *Builder) WithMiddlewares(mm ...middleware.Func) *Builder

WithMiddlewares adds generic middlewares to the default HTTP component.

Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.

func (*Builder) WithReadyCheck deprecated added in v0.32.0

func (b *Builder) WithReadyCheck(rcf patronhttp.ReadyCheckFunc) *Builder

WithReadyCheck overrides the default readiness check of the default HTTP component.

Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.

func (*Builder) WithRouter added in v0.66.0

func (b *Builder) WithRouter(handler http.Handler) *Builder

WithRouter replaces the default v1 HTTP component with a new component v2 based on http.Handler.

func (*Builder) WithRoutesBuilder deprecated added in v0.32.0

func (b *Builder) WithRoutesBuilder(rb *patronhttp.RoutesBuilder) *Builder

WithRoutesBuilder adds routes builder to the default HTTP component.

Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.

func (*Builder) WithSIGHUP added in v0.32.0

func (b *Builder) WithSIGHUP(handler func()) *Builder

WithSIGHUP adds a custom handler for handling SIGHUP.

func (*Builder) WithUncompressedPaths deprecated added in v0.49.1

func (b *Builder) WithUncompressedPaths(p ...string) *Builder

WithUncompressedPaths defines a list of paths which the compre ssion middleware will skip.

Deprecated: Please use the new v2 package. This package is frozen and no new functionality will be added.

type Component added in v0.2.0

type Component interface {
	Run(ctx context.Context) error
}

Component interface for implementing service components.

type Config added in v0.46.0

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

Config for setting up the builder.

type Option added in v0.2.0

type Option func(*Config)

Option for providing function configuration.

func LogFields added in v0.46.0

func LogFields(fields map[string]interface{}) Option

LogFields options to pass in additional log fields.

func Logger added in v0.46.0

func Logger(logger log.Logger) Option

Logger to pass in custom logger.

func TextLogger added in v0.46.0

func TextLogger() Option

TextLogger to use Go's standard logger.

Directories

Path Synopsis
Package cache provide abstractions for concrete cache implementations.
Package cache provide abstractions for concrete cache implementations.
lru
Package lru is the concrete implementation of the cache abstraction.
Package lru is the concrete implementation of the cache abstraction.
redis
Package redis is the concrete implementation of the cache abstraction.
Package redis is the concrete implementation of the cache abstraction.
client
amqp
Package amqp provides a client with included tracing capabilities.
Package amqp provides a client with included tracing capabilities.
amqp/v2
Package v2 provides a client with included tracing capabilities.
Package v2 provides a client with included tracing capabilities.
es
Package es provides a client with included tracing capabilities.
Package es provides a client with included tracing capabilities.
grpc
Package grpc provides a client implementation for gRPC with tracing and metrics included.
Package grpc provides a client implementation for gRPC with tracing and metrics included.
http
Package http provides a client with included tracing capabilities.
Package http provides a client with included tracing capabilities.
http/encoding/json
Package json provides helper functions to handle requests and responses.
Package json provides helper functions to handle requests and responses.
kafka
Package kafka provides a client with included tracing capabilities.
Package kafka provides a client with included tracing capabilities.
kafka/v2
Package v2 provides a client with included tracing capabilities.
Package v2 provides a client with included tracing capabilities.
mongo
Package mongo provides a client implementation for mongo with tracing and metrics included.
Package mongo provides a client implementation for mongo with tracing and metrics included.
mqtt
Package mqtt provides an instrumented publisher for MQTT v5.
Package mqtt provides an instrumented publisher for MQTT v5.
redis
Package redis provides a client with included tracing capabilities.
Package redis provides a client with included tracing capabilities.
sns
Package sns provides a wrapper for publishing messages to AWS SNS.
Package sns provides a wrapper for publishing messages to AWS SNS.
sql
Package sql provides a client with included tracing capabilities.
Package sql provides a client with included tracing capabilities.
sqs
Package sqs provides a set of common interfaces and structs for publishing messages to AWS SQS.
Package sqs provides a set of common interfaces and structs for publishing messages to AWS SQS.
cmd
component
amqp
Package amqp provides a native consumer for the AMQP protocol.
Package amqp provides a native consumer for the AMQP protocol.
async
Package async provides async consumer abstractions and component.
Package async provides async consumer abstractions and component.
async/amqp
Package amqp provides consumer implementation with included tracing capabilities.
Package amqp provides consumer implementation with included tracing capabilities.
async/kafka
Package kafka provides consumer abstractions and base functionality with included tracing capabilities.
Package kafka provides consumer abstractions and base functionality with included tracing capabilities.
async/kafka/group
Package group provides a consumer group implementation.
Package group provides a consumer group implementation.
async/kafka/simple
Package simple provides a simple consumer implementation without consumer groups.
Package simple provides a simple consumer implementation without consumer groups.
grpc
Package grpc provides a gRPC component with included observability.
Package grpc provides a gRPC component with included observability.
http
Package http provides an HTTP component with included observability.
Package http provides an HTTP component with included observability.
http/auth
Package auth provides abstractions for concrete implementations.
Package auth provides abstractions for concrete implementations.
http/auth/apikey
Package apikey is a concrete implementation of the auth abstractions.
Package apikey is a concrete implementation of the auth abstractions.
http/cache
Package cache provides a cache control and implementation components for http routes.
Package cache provides a cache control and implementation components for http routes.
http/v2
Package v2 provides a ready to use HTTP component.
Package v2 provides a ready to use HTTP component.
http/v2/encoding/json
Package json contains helper methods to handler requests and responses more easily.
Package json contains helper methods to handler requests and responses more easily.
kafka
Package kafka provides some shared interfaces for the Kafka components.
Package kafka provides some shared interfaces for the Kafka components.
kafka/group
Package group provides kafka consumer group component implementation.
Package group provides kafka consumer group component implementation.
sqs
Package sqs provides a native consumer for AWS SQS.
Package sqs provides a native consumer for AWS SQS.
Package correlation provides support for correlation id's and propagation.
Package correlation provides support for correlation id's and propagation.
Package encoding provides abstractions for concrete encoding implementations.
Package encoding provides abstractions for concrete encoding implementations.
json
Package json is a concrete implementation of the encoding abstractions.
Package json is a concrete implementation of the encoding abstractions.
protobuf
Package protobuf is a concrete implementation of the encoding abstractions.
Package protobuf is a concrete implementation of the encoding abstractions.
Package errors provides useful error handling implementations.
Package errors provides useful error handling implementations.
sqs
internal
validation
Package validation provides validation implementations.
Package validation provides validation implementations.
log
Package log provides logging abstractions.
Package log provides logging abstractions.
std
Package std is the implementation of the logger interface with the standard log package.
Package std is the implementation of the logger interface with the standard log package.
zerolog
Package zerolog is a concrete implementation of the log abstractions.
Package zerolog is a concrete implementation of the log abstractions.
reliability
circuitbreaker
Package circuitbreaker provides a circuit breaker pattern implementation.
Package circuitbreaker provides a circuit breaker pattern implementation.
retry
Package retry provides a retry pattern implementation.
Package retry provides a retry pattern implementation.
test
aws
Package trace provides trace support and helper methods.
Package trace provides trace support and helper methods.

Jump to

Keyboard shortcuts

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