Documentation

This is the complete documentation for frx, including detailed usage instructions and examples for all modules.

frx v0.0.5

frx is a collection of Go libraries designed to provide convenient wrappers for common development tasks. It contains non-business logic code, transport frameworks, and standard libraries for large-scale project development, as well as useful toolkits.

The project is organized into several modules, each focusing on a specific aspect of Go development:

  • ctxcache - Context caching for HTTP requests
  • errorx - Comprehensive error code management
  • httpx - Enhanced HTTP client and server wrappers
  • idgen - Distributed unique ID generation
  • logs - Structured logging functionality
  • lang - Go language extension utilities

Installation

To use frx in your Go project, you can install individual modules or the entire package:

Install the entire package

1go get github.com/crazyfrankie/frx@latest

auth(JWT authentication)

A comprehensive JWT authentication system supporting both Gin and gRPC contexts with flexible token extraction and validation.

ctxcache(context caching middleware)

Thread-safe context caching for HTTP requests, enabling efficient data sharing within request lifecycles without repeated computations or database queries.

cshash(consistent hashing)

Thread-safe consistent hashing implementation with virtual nodes support, ideal for distributed systems and load balancing scenarios.

config(configuration management)

Flexible configuration management system supporting multiple sources (files, environment variables, remote config centers) with unified reading, watching, and parsing interfaces. Protobuf is recommended for defining configuration structures.

errorx(error code management)

Comprehensive error code management with status codes, stack traces, and configurable error registration for structured error handling.

encoding(serialization codec system)

Thread-safe serialization codec system supporting multiple formats (JSON, XML, YAML, Protocol Buffers, Form) with automatic registration and content-type handling.

htr(HTTP to RPC converter)

A convenient bridge between HTTP requests and gRPC calls, simplifying the process of converting HTTP endpoints to RPC service calls.

httpx(enhanced HTTP client)

A fluent, chainable HTTP client with enhanced functionality for building and executing HTTP requests with automatic error handling and JSON support.

idgen(distributed unique ID generator)

Distributed unique ID generation using Redis as the coordination backend, suitable for high-concurrency scenarios.

jsoncache(JSON caching)

Type-safe JSON caching functionality with Redis backend, supporting generic types for compile-time type safety.

lang(Go language extensions)

Utility functions and extensions for common Go programming tasks, organized into several sub-packages.

logs(structured logging)

A comprehensive logging system with multiple interfaces, level-based filtering, and flexible output configuration, designed for high-performance applications.

zapx(enhanced Zap logging)

Enhanced logging capabilities built on top of Uber’s Zap logger, with additional features like sensitive data masking.