lori

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 13 Imported by: 0

README

lori

Build Status Go Reference

1.介绍

lori 是一款基于golang的分布式服务器框架,目标是快速构建服务。

  • http server 基于gin
  • grpc server
  • grpc client
  • tcp server 基于 zinx v1.1.20 改造, 适配lori的transport。
2.安装
go get github.com/cr-mao/lori@v0.0.3
3.模块化设计

服务注册发现

  • consul
go get github.com/cr-mao/lori/registry/consul@v0.0.3

指标监控

  • prometheus

日志

  • zap

参考kratos,go-zero,due框架,iam 极客时间go语言项目实战

Documentation

Index

Constants

View Source
const Release = "v0.0.0"

lori 当前版本

View Source
const Website = "https://github.com/cr-mao/lori"

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. app 上下文信息

Types

type App

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

func New

func New(opts ...Option) *App

func (*App) Endpoint

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

Endpoint returns endpoints. app 服务的端点

func (*App) ID

func (a *App) ID() string

ID returns app instance id. app实例id

func (*App) Metadata

func (a *App) Metadata() map[string]string

Metadata returns service metadata.

func (*App) Name

func (a *App) Name() string

Name returns service name. app名

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() (err error)

Stop gracefully stops the application.

func (*App) Version

func (a *App) Version() string

Version returns app version. app版本

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. 获得app 上下文信息

type Option

type Option func(o *options)

Option is an application option.

func AfterStart

func AfterStart(fn func(context.Context) error) Option

AfterStart run funcs after app starts

func AfterStop

func AfterStop(fn func(context.Context) error) Option

AfterStop run funcs after app stops

func BeforeStart

func BeforeStart(fn func(context.Context) error) Option

BeforeStart run funcs before app starts

func BeforeStop

func BeforeStop(fn func(context.Context) error) Option

BeforeStop run funcs before app stops

func Signal

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

Signal with exit signals.

func WithContext

func WithContext(ctx context.Context) Option

Context with service context.

func WithEndpoint

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

Endpoint with service endpoint.

func WithID

func WithID(id string) Option

ID with service id.

func WithLogger

func WithLogger(logger log.Logger) Option

Logger with service logger.

func WithMetadata

func WithMetadata(md map[string]string) Option

Metadata with service metadata.

func WithName

func WithName(name string) Option

Name with service name.

func WithRegistrar

func WithRegistrar(r registry.Registrar) Option

Registrar with service registry.

func WithRegistrarTimeout

func WithRegistrarTimeout(t time.Duration) Option

RegistrarTimeout with registrar timeout.

func WithServer

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

Server with transport servers.

func WithStopTimeout

func WithStopTimeout(t time.Duration) Option

StopTimeout with app stop timeout.

func WithVersion

func WithVersion(version string) Option

Version with service version.

Directories

Path Synopsis
Package errors provides simple error handling primitives.
Package errors provides simple error handling primitives.
internal
log
zap
consul Module
rtcp/iface
@Title iclient.go @Description Provides all interface declarations for the Client abstraction layer.
@Title iclient.go @Description Provides all interface declarations for the Client abstraction layer.

Jump to

Keyboard shortcuts

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