patron

package module
v0.74.0 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

README

patron CI codecov Go Report Card GoDoc GitHub releaseFOSSA Status

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 slog, tracing and metrics with OpenTelemetry.

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.22 as a minimum.

Code coverage

Code coverage

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 WithComponents to handle the processing of sync and async requests. The Service can set up as many components as 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 slog, tracing and metrics with OpenTelemetry.

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 Component added in v0.2.0

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

Component interface for implementing Service components.

type OptionFunc added in v0.4.0

type OptionFunc func(svc *Service) error

func WithJSONLogger added in v0.74.0

func WithJSONLogger() OptionFunc

WithJSONLogger to use Go's slog package.

func WithLogFields added in v0.74.0

func WithLogFields(attrs ...slog.Attr) OptionFunc

WithLogFields options to pass in additional log fields.

func WithSIGHUP added in v0.74.0

func WithSIGHUP(handler func()) OptionFunc

WithSIGHUP adds a custom handler for handling WithSIGHUP.

type Service

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

Service is responsible for managing and setting up everything. The Service will start by default an HTTP component in order to host management endpoint.

func New

func New(name, version string, options ...OptionFunc) (*Service, error)

New creates a new Service instance.

func (*Service) Run

func (s *Service) Run(ctx context.Context, components ...Component) error

Run starts the service with the provided components.

Directories

Path Synopsis
Package cache provides abstractions to allow the creation of concrete implementations.
Package cache provides abstractions to allow the creation of concrete implementations.
lru
Package lru implements a LRU based cache.
Package lru implements a LRU based cache.
redis
Package redis contains the concrete implementation of a cache that supports TTL.
Package redis contains the concrete implementation of a cache that supports TTL.
client
amqp
Package amqp provides a client with included tracing capabilities.
Package amqp 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.
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
sql
Package sql provides a client with included tracing capabilities.
Package sql provides a client with included tracing capabilities.
sqs
component
amqp
Package amqp provides a native consumer for the AMQP protocol.
Package amqp provides a native consumer for the AMQP protocol.
grpc
Package grpc provides a gRPC component with included observability.
Package grpc provides a gRPC component with included observability.
http
Package v2 provides a ready to use HTTP component.
Package v2 provides a ready to use HTTP component.
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.
kafka
Package kafka provides some shared interfaces for the Kafka components.
Package kafka provides some shared interfaces for the Kafka components.
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 supporting concrete encoding implementations.
Package encoding provides abstractions for supporting 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.
internal
validation
Package validation provides validation implementations.
Package validation provides validation implementations.
Package observability provides functionality for initializing OpenTelemetry's traces and metrics.
Package observability provides functionality for initializing OpenTelemetry's traces and metrics.
log
Package log provides logging abstractions.
Package log provides logging 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.

Jump to

Keyboard shortcuts

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