fox

package module
v0.0.0-...-b8a7096 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2024 License: MIT Imports: 17 Imported by: 0

README

fox

微服务框架

Documentation

Overview

Package fox MIT License

# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package fox MIT License

# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package fox MIT License

# Copyright (c) 2024 go-fox Author https://github.com/go-fox/fox

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppCommit

func AppCommit() string

AppCommit 返回git提交的hash值

func AppId

func AppId() string

AppId 当前应用唯一标识

func AppName

func AppName() string

AppName 应用名称

func AppRegion

func AppRegion() string

AppRegion 部属地域

func AppVersion

func AppVersion() string

AppVersion 应用版本

func AppVersionSting

func AppVersionSting() string

AppVersionSting 获取版本字符串 (format is "Version/CommitHash" or only "Version" if CommitHash is empty)

func AppZone

func AppZone() string

AppZone 应用部属的分区

func BuildTime

func BuildTime() string

BuildTime 构建时间

func GoVersion

func GoVersion() string

GoVersion go的运行版本

func HostName

func HostName() string

HostName 主机名

func NewContext

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

NewContext 创建附带服务信息的上下文

func PrintVersion

func PrintVersion()

PrintVersion print version

func SetAppRegion

func SetAppRegion(region string)

SetAppRegion 设置部属区域

func SetAppZone

func SetAppZone(z string)

SetAppZone set app zone

func StartTime

func StartTime() string

StartTime 项目启动时间

func VersionFox

func VersionFox() string

VersionFox fox version

Types

type AppInfo

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

AppInfo 应用信息

func FromContext

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

FromContext 从上下文中获取服务信息

type Application

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

Application application

func New

func New(opts ...Option) *Application

New create application

func (*Application) Endpoint

func (app *Application) Endpoint() []string

Endpoint registry endpoint

func (*Application) ID

func (app *Application) ID() string

ID app id

func (*Application) Metadata

func (app *Application) Metadata() map[string]string

Metadata app metadata

func (*Application) Name

func (app *Application) Name() string

Name app name

func (*Application) Run

func (app *Application) Run() error

Run 启动

func (*Application) Stop

func (app *Application) Stop() (err error)

Stop 停止应用

func (*Application) Version

func (app *Application) Version() string

Version app version

type HookFunc

type HookFunc func(ctx context.Context)

HookFunc 钩子回调方法

type HookType

type HookType uint

HookType 定义 hook类型

const (
	ModName              = "app" // ModName mod name
	BeforeStart HookType = iota  // BeforeStart hook enum
	BeforeStop                   // BeforeStop hook enum
	AfterStart                   // AfterStart hook enum
	AfterStop                    // AfterStop hook enum
)

type Option

type Option func(o *options)

Option app option

func AddHooks

func AddHooks(hookType HookType, hooks ...HookFunc) Option

AddHooks add hooks

func Context

func Context(ctx context.Context) Option

Context app context

func HideBanner

func HideBanner() Option

HideBanner hide print banner

func Hooks

func Hooks(hookType HookType, hooks ...HookFunc) Option

Hooks with hooks options

func Id

func Id(id string) Option

Id app id

func Logger

func Logger(log *slog.Logger) Option

Logger with logger

func MaxProc

func MaxProc(maxProc int64) Option

MaxProc with max procs

func Metadata

func Metadata(metadata map[string]string) Option

Metadata with app metadata

func Name

func Name(name string) Option

Name app name

func Region

func Region(region string) Option

Region with app Region

func RegistrarTimeout

func RegistrarTimeout(timeout time.Duration) Option

RegistrarTimeout with registry.Registrar timeout

func Registry

func Registry(reg registry.Registry) Option

Registry with registry

func Server

func Server(servers ...transport.Server) Option

Server with server

func StopTimeout

func StopTimeout(timeout time.Duration) Option

StopTimeout with stop timeout

func Version

func Version(version string) Option

Version with an app version

func Zone

func Zone(zone string) Option

Zone with app zone

Directories

Path Synopsis
api
protocol
Package protocol MIT License
Package protocol MIT License
Package codec MIT License
Package codec MIT License
json
Package json MIT License
Package json MIT License
proto
Package proto MIT License
Package proto MIT License
toml
Package toml MIT License
Package toml MIT License
xml
Package xml MIT License
Package xml MIT License
yaml
Package yaml MIT License
Package yaml MIT License
Package config MIT License
Package config MIT License
file
Package file MIT License
Package file MIT License
contrib
auth/token Module
cache Module
clients/redis Module
i18n Module
Package errors MIT License
Package errors MIT License
internal
context
Package context MIT License
Package context MIT License
cycle
Package cycle MIT License
Package cycle MIT License
matcher
Package matcher MIT License
Package matcher MIT License
signals
Package signals MIT License
Package signals MIT License
strings
Package strings MIT License
Package strings MIT License
Package middleware MIT License
Package middleware MIT License
Package selector MIT License
Package selector MIT License
balancer/random
Package random MIT License
Package random MIT License
base
Package base MIT License
Package base MIT License
node/direct
Package direct MIT License
Package direct MIT License
Package transport MIT License
Package transport MIT License
grpc
Package grpc MIT License
Package grpc MIT License
grpc/resolver/direct
Package direct MIT License
Package direct MIT License
grpc/resolver/discovery
Package discovery MIT License
Package discovery MIT License
http
Package http MIT License
Package http MIT License
http/binding
Package binding MIT License
Package binding MIT License
websocket
Package websocket MIT License
Package websocket MIT License

Jump to

Keyboard shortcuts

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