fabrica-kit

module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2025 License: MIT

README ΒΆ

Fabrica Kit

Fabrica Kit is a core toolkit library for the go-pantheon ecosystem, providing essential functionalities and integrations for building robust game server microservices. This kit builds upon the go-pantheon infrastructure to offer standardized components for logging, error handling, tracing, routing, and more.

go-pantheon Ecosystem

go-pantheon is a high-performance, highly available game server cluster solution framework based on go-kratos. Fabrica Kit, as a framework toolkit, provides support for the following core components:

  • Roma: Game core logic services
  • Janus: Gateway service for client connection handling and request forwarding
  • Lares: Account service for user authentication and account management
  • Senate: Backend management service providing operational interfaces

Core Features

  • πŸ“ Standardized logging system (xlog/)
  • πŸ” Tracing and metrics collection (trace/, metrics/)
  • 🌐 Routing and load balancing (router/)
  • πŸ›‘οΈ Error handling and API error standardization (xerrors/)
  • πŸ”„ Communication tunnel abstraction (tunnel/)
  • πŸ“Š Context extensions (xcontext/)
  • πŸ“ˆ Project metadata (profile/)
  • 🌍 IP address handling tools (ip/)
  • πŸ”’ Version control and compatibility checking (version/)

Technology Stack

Technology/Component Purpose Version
Go Primary development language 1.23+
go-kratos Microservices framework v2.8.4
OpenTelemetry Distributed tracing and metrics v1.35.0
Zap High-performance structured logging v1.27.0
go-redis Redis client v9.7.3
gRPC Remote procedure call v1.71.1
GORM Object-relational mapping v1.25.12

Quick Start

Installation
go get github.com/go-pantheon/fabrica-kit

Project Structure

.
β”œβ”€β”€ xlog/               # Logging tools
β”œβ”€β”€ xerrors/            # Error handling
β”œβ”€β”€ trace/              # Distributed tracing
β”œβ”€β”€ metrics/            # Metrics collection
β”œβ”€β”€ router/             # Routing and load balancing
β”‚   β”œβ”€β”€ balancer/       # Load balancing implementation
β”‚   β”œβ”€β”€ conn/           # Connection management
β”‚   └── routetable/     # Routing table
β”œβ”€β”€ tunnel/             # Communication tunnel abstraction
β”œβ”€β”€ xcontext/           # Context extensions
β”œβ”€β”€ profile/            # Project metadata
β”œβ”€β”€ ip/                 # IP address handling
└── version/            # Version tools

Integration with go-pantheon Components

Fabrica Kit is designed to be imported by other go-pantheon components to provide common functionality:

import (
    // For logging in Roma
    "github.com/go-pantheon/fabrica-kit/xlog"

    // For routing in Janus
    "github.com/go-pantheon/fabrica-kit/router"

    // For error handling in Lares
    "github.com/go-pantheon/fabrica-kit/xerrors"

    // For tracing in all services
    "github.com/go-pantheon/fabrica-kit/trace"
)

Development Guide

Adding New Features

When adding new features:

  1. Create a new package or add to an existing one based on functionality
  2. Implement features with proper error handling
  3. Write comprehensive unit tests
  4. Document usage with examples
  5. Run tests to ensure functionality works correctly
Contribution Guidelines
  1. Fork this repository
  2. Create a feature branch
  3. Submit changes with comprehensive tests
  4. Ensure all tests pass
  5. Submit a Pull Request

License

This project is licensed under the terms specified in the LICENSE file.

Directories ΒΆ

Path Synopsis
Package ip provides utilities for IP address operations, including detection of internal IPs, extracting addresses from connections, and client IP identification in request contexts.
Package ip provides utilities for IP address operations, including detection of internal IPs, extracting addresses from connections, and client IP identification in request contexts.
Package metrics provides functionality for metrics collection and monitoring using OpenTelemetry for both server and client operations.
Package metrics provides functionality for metrics collection and monitoring using OpenTelemetry for both server and client operations.
Package profile provides environment profile and configuration utilities for application setup and runtime behavior control.
Package profile provides environment profile and configuration utilities for application setup and runtime behavior control.
Package router provides routing capabilities for service discovery and network communication in distributed systems.
Package router provides routing capabilities for service discovery and network communication in distributed systems.
balancer
Package balancer provides gRPC load balancing functionality for service discovery and routing in distributed systems.
Package balancer provides gRPC load balancing functionality for service discovery and routing in distributed systems.
conn
Package conn provides utilities for managing gRPC client connections with load balancing, service discovery, and middleware support.
Package conn provides utilities for managing gRPC client connections with load balancing, service discovery, and middleware support.
routetable
Package routetable provides functionality for distributed routing tables used for tracking and managing service instances and their connection states.
Package routetable provides functionality for distributed routing tables used for tracking and managing service instances and their connection states.
routetable/redis
Package redis provides a Redis-based implementation of the route table.
Package redis provides a Redis-based implementation of the route table.
Package trace provides OpenTelemetry tracing functionality for various components, including GORM database operations and HTTP requests.
Package trace provides OpenTelemetry tracing functionality for various components, including GORM database operations and HTTP requests.
Package tunnel provides interfaces and functionality for managing communication tunnels between services, supporting messaging, routing and forwarding capabilities.
Package tunnel provides interfaces and functionality for managing communication tunnels between services, supporting messaging, routing and forwarding capabilities.
Package version provides utilities for parsing and comparing version strings to ensure compatibility and properly handle versioned resources.
Package version provides utilities for parsing and comparing version strings to ensure compatibility and properly handle versioned resources.
Package xcontext provides context-related utilities for propagating and accessing metadata through the service chain, including user IDs, routing information, and status data.
Package xcontext provides context-related utilities for propagating and accessing metadata through the service chain, including user IDs, routing information, and status data.
Package xerrors provides standardized error types and error handling utilities for application-specific errors, including API, database, and routing errors.
Package xerrors provides standardized error types and error handling utilities for application-specific errors, including API, database, and routing errors.
Package xlog provides extended logging functionality using structured loggers with support for multiple log formats, levels, and integration with tracing.
Package xlog provides extended logging functionality using structured loggers with support for multiple log formats, levels, and integration with tracing.

Jump to

Keyboard shortcuts

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