gosrvlib

module
v1.70.2 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT

README

gosrvlib

Go Service Library

This Open Source project contains a collection of high-quality GO (golang) packages.

The packages documentation is available at: https://pkg.go.dev/github.com/Vonage/gosrvlib

This package collection forms the base structure for production-ready web-services.

A new service can be generated by using the command make project CONFIG=project.cfg. The new generated project name, description, etc..., can be set in the file specified via the CONFIG parameter.

Each package follows the same conventions and they can be individually imported in any project.

Go Reference
check Coverage Status Coverage Lines of Code
Go Report Card Quality Gate Status Reliability Rating Maintainability Rating Security Rating
Bugs Vulnerabilities Technical Debt Code Smells


TOC


Quick Start

This project includes a Makefile that allows you to test and build the project in a Linux-compatible system with simple commands.
All the artifacts and reports produced using this Makefile are stored in the target folder.

All the packages listed in the resources/docker/Dockerfile.dev file are required in order to build and test all the library options in the current environment. Alternatively, everything can be built inside a Docker container using the command "make dbuild".

To see all available options:

make help

To build the project inside a Docker container (requires Docker):

make dbuild

An arbitrary make target can be executed inside a Docker container by specifying the "MAKETARGET" parameter:

MAKETARGET='deps mod qa example' make dbuild

The list of make targets can be obtained by typing make

The base Docker building environment is defined in the following Dockerfile:

resources/docker/Dockerfile.dev

To download all dependencies:

make deps

To update the mod file:

make mod

To execute all the default test builds and generate reports in the current environment:

make qa

To format the code (please use this command before submitting any pull request):

make format

Running all tests

Before committing the code, please format it and check if it passes all tests using

DEVMODE=LOCAL make format clean mod deps generate qa example

Examples

Please check the examples folder for an example of a service based on this library.

The following command generates a new project from the example using the data set in the project.cfg file:

make project CONFIG=project.cfg

Directories

Path Synopsis
pkg
awsopt
Package awsopt provides functions to configure common AWS options.
Package awsopt provides functions to configure common AWS options.
bootstrap
Package bootstrap provides a simple way to bootstrap an application with a managed logging framework, metrics and application context.
Package bootstrap provides a simple way to bootstrap an application with a managed logging framework, metrics and application context.
config
Package config handles the configuration of the program.
Package config handles the configuration of the program.
decint
Package decint provides utility functions to parse and represent decimal values as integer with a set precision.
Package decint provides utility functions to parse and represent decimal values as integer with a set precision.
enumbitmap
Package enumbitmap provides functions to encode slices of enumeration strings into integer bitmap values and vice versa.
Package enumbitmap provides functions to encode slices of enumeration strings into integer bitmap values and vice versa.
enumcache
Package enumcache provides simple methods to store and retrieve enumerations with a numerical ID and string name.
Package enumcache provides simple methods to store and retrieve enumerations with a numerical ID and string name.
enumdb
Package enumdb provides simple methods to store and retrieve enumerations from database tables.
Package enumdb provides simple methods to store and retrieve enumerations from database tables.
errtrace
Package errtrace provides utilities to annotate errors.
Package errtrace provides utilities to annotate errors.
filter
Package filter provides generic filtering capabilities for struct slices.
Package filter provides generic filtering capabilities for struct slices.
healthcheck
Package healthcheck provides a simple way to define health checks for external services or components.
Package healthcheck provides a simple way to define health checks for external services or components.
httpclient
Package httpclient provides an instrumented HTTP client with the addition of the traceID header and logging.
Package httpclient provides an instrumented HTTP client with the addition of the traceID header and logging.
httpretrier
Package httpretrier allow to retry HTTP requests based on HTTP status code boolean conditions.
Package httpretrier allow to retry HTTP requests based on HTTP status code boolean conditions.
httpreverseproxy
Package httpreverseproxy provides an HTTP Reverse Proxy that takes an incoming request and sends it to another server, proxying the response back to the client.
Package httpreverseproxy provides an HTTP Reverse Proxy that takes an incoming request and sends it to another server, proxying the response back to the client.
httpserver
Package httpserver defines a default HTTP server with common routes.
Package httpserver defines a default HTTP server with common routes.
httpserver/route
Package route is deprecated.
Package route is deprecated.
httputil
Package httputil contains a collection of HTTP request and response utility functions.
Package httputil contains a collection of HTTP request and response utility functions.
httputil/jsendx
Package jsendx implements a custom JSEND model to wrap HTTP responses in a JSON object with default fields.
Package jsendx implements a custom JSEND model to wrap HTTP responses in a JSON object with default fields.
ipify
Package ipify allows to get the public IP address of this service instance via the ipify API (https://www.ipify.org/).
Package ipify allows to get the public IP address of this service instance via the ipify API (https://www.ipify.org/).
jwt
Package jwt provides JWT Auth handlers.
Package jwt provides JWT Auth handlers.
kafka
Package kafka provides a simple abstraction to send and pull Apache Kafka messages.
Package kafka provides a simple abstraction to send and pull Apache Kafka messages.
kafkacgo
Package kafkacgo provides a simple abstraction to send and pull Apache Kafka messages.
Package kafkacgo provides a simple abstraction to send and pull Apache Kafka messages.
logging
Package logging provides an interface to configure and use the logging framework in a consistent way across multiple applications.
Package logging provides an interface to configure and use the logging framework in a consistent way across multiple applications.
metrics
Package metrics defines a general interface for metrics instrumentation.
Package metrics defines a general interface for metrics instrumentation.
metrics/prometheus
Package prometheus implements the metrics interface with Prometheus.
Package prometheus implements the metrics interface with Prometheus.
metrics/statsd
Package statsd implements the metrics interface with StatsD.
Package statsd implements the metrics interface with StatsD.
mysqllock
Package mysqllock provides a distributed locking mechanism leveraging MySQL internal functions.
Package mysqllock provides a distributed locking mechanism leveraging MySQL internal functions.
paging
Package paging contains utilities to handle pagination.
Package paging contains utilities to handle pagination.
periodic
Package periodic allow to execute a specified function periodically.
Package periodic allow to execute a specified function periodically.
profiling
Package profiling is used to expose runtime profiling data (pprof).
Package profiling is used to expose runtime profiling data (pprof).
randkey
Package randkey creates a random uint64 key.
Package randkey creates a random uint64 key.
redact
Package redact contains utilities functions to obscure sensitive data.
Package redact contains utilities functions to obscure sensitive data.
retrier
Package retrier allow to retry execute a function in case of errors.
Package retrier allow to retry execute a function in case of errors.
s3
Package s3 provides a client for AWS S3 bucket.
Package s3 provides a client for AWS S3 bucket.
slack
Package slack is a basic Slack API client to send messages via a Webhook.
Package slack is a basic Slack API client to send messages via a Webhook.
sleuth
Package sleuth contains the implementation of a basic Sleuth.io API client.
Package sleuth contains the implementation of a basic Sleuth.io API client.
sqlconn
Package sqlconn provides a simple way to manage a SQL-based database connection.
Package sqlconn provides a simple way to manage a SQL-based database connection.
sqltransaction
Package sqltransaction helps executing a function inside an SQL transaction.
Package sqltransaction helps executing a function inside an SQL transaction.
sqlutil
Package sqlutil provides SQL utilities.
Package sqlutil provides SQL utilities.
sqlxtransaction
Package sqlxtransaction helps executing a function inside an SQLX transaction.
Package sqlxtransaction helps executing a function inside an SQLX transaction.
sqs
Package sqs provides a basic client for AWS SQS (Amazon Simple Queue Service).
Package sqs provides a basic client for AWS SQS (Amazon Simple Queue Service).
stringkey
Package stringkey creates a key from multiple strings.
Package stringkey creates a key from multiple strings.
testutil
Package testutil provides common testing utility functions.
Package testutil provides common testing utility functions.
threadsafe
Package threadsafe provides a collection of thread-safe functions that can be safely used between multiple goroutines.
Package threadsafe provides a collection of thread-safe functions that can be safely used between multiple goroutines.
threadsafe/tsmap
Package tsmap provides a collection of thread-safe map functions that can be safely used between multiple goroutines.
Package tsmap provides a collection of thread-safe map functions that can be safely used between multiple goroutines.
threadsafe/tsslice
Package tsslice provides a collection of thread-safe slice functions that can be safely used between multiple goroutines.
Package tsslice provides a collection of thread-safe slice functions that can be safely used between multiple goroutines.
traceid
Package traceid provide a simple mechanism to save/extract a Trace ID HTTP header to/from a context.Context and http.Request.
Package traceid provide a simple mechanism to save/extract a Trace ID HTTP header to/from a context.Context and http.Request.
typeutil
Package typeutil contains a collection of type-related utility functions.
Package typeutil contains a collection of type-related utility functions.
uid
Package uid provides fast functions to generate simple time-and-random-based unique identifiers.
Package uid provides fast functions to generate simple time-and-random-based unique identifiers.
uidc
Package uidc provides cryptographic-grade functions to generate simple time-and-random-based unique identifiers.
Package uidc provides cryptographic-grade functions to generate simple time-and-random-based unique identifiers.
validator
Package validator wraps https://github.com/go-playground/validator to provide value validations for structs and individual fields based on tags.
Package validator wraps https://github.com/go-playground/validator to provide value validations for structs and individual fields based on tags.

Jump to

Keyboard shortcuts

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