af_go_frame

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 13 Imported by: 0

README

Translate to: English | 简体中文

Af-Go-Frame

af-go-frame is a light wight Go microservices framework base on Gin, And integrated library of all modern web application frameworks, making it a breeze to get started with the framework.

Goals

we dedicated to boosts your productivity. With the integration of excellent resources and further support, programmers can get rid of most issues might encounter in the field of distributed systems and software engineering such that they are allowed to focus on the release of businesses only.

Principles
  • Simple: Appropriate design with plain and easy code.
  • General: Cover the various utilities for business development.
  • Highly efficient: Speeding up the efficiency of businesses upgrading.
  • Stable: The base libs validated in the production environment have the characteristics of high testability, high coverage as well as high security and reliability.
  • Robust: Eliminating misusing through high quality of the base libs.
  • High-performance: Optimal performance, with zap logger insider
  • Expandability: Properly designed interfaces where you can expand utilities such as base libs to meet your further requirements.
  • Fault-tolerance: Designed against failure, enhance the understanding and exercising of SRE.
  • Toolchain: Includes an extensive toolchain.

Features

  • Config :support multi config source, multi config file
  • Logger :standard Log interface, Base on zap

Getting Started

Dependency

we provide demo project blow:

License

The af-go-frame framework is open-sourced software licensed under the MIT license.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, s AppInfo) context.Context

NewContext returns a new Context that carries value.

Types

type App

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

func New

func New(opts ...Option) *App

New create an application lifecycle manager.

func (*App) Endpoint

func (a *App) Endpoint() []string

Endpoint returns endpoints.

func (*App) ID

func (a *App) ID() string

func (*App) Name

func (a *App) Name() string

func (*App) Run

func (a *App) Run() error

Run executes all OnStart hooks registered with the application's Lifecycle.

func (*App) Stop

func (a *App) Stop() error

Stop gracefully stops the application.

type AppInfo

type AppInfo interface {
	ID() string
	Name() string
	//Version() string
	//Metadata() map[string]string
	Endpoint() []string
}

AppInfo is application context value.

func FromContext

func FromContext(ctx context.Context) (s AppInfo, ok bool)

FromContext returns the Transport value stored in ctx, if any.

type Application

type Application struct {
	Name     string
	Version  string
	Addr     string
	ConfPath string
}

type Option

type Option func(o *options)

func Context

func Context(ctx context.Context) Option

Context with service context.

func Endpoint

func Endpoint(endpoints ...*url.URL) Option

Endpoint with service endpoint.

func ID

func ID(id string) Option

ID 设置Server的ID

func Logger

func Logger(logger log.Logger) Option

Logger with service logger.

func Name

func Name(name string) Option

Name 设置Server的Name

func Registrar

func Registrar(r registry.Registrar) Option

Registrar with service registry.

func RegistrarTimeout

func RegistrarTimeout(t time.Duration) Option

RegistrarTimeout with registrar timeout.

func Server

func Server(srv ...transport.Server) Option

Server with transport servers.

func Signal

func Signal(sigs ...os.Signal) Option

Signal with exit signals.

func StopTimeout

func StopTimeout(t time.Duration) Option

StopTimeout with app stop timeout.

Jump to

Keyboard shortcuts

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