gaia

package module
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: MIT Imports: 13 Imported by: 0

README

Gaia

Gaia[ˈɡaɪə] 一个轻量级gRPC业务框架

安装 protoc

$ go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
$ go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest

编译

protoc --go_out=. --go_opt=paths=source_relative \
    --go-grpc_out=. --go-grpc_opt=paths=source_relative \
    helloworld/helloworld.proto

感谢

Documentation

Index

Constants

View Source
const (
	Name    = "Gaia"
	Version = "v1.6.1"
)

Name and Version info of this framework, used for statistics and debug

Variables

This section is empty.

Functions

func NewContext

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

NewContext returns a new Context that carries value.

Types

type App added in v1.2.1

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

func FromContext

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

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

type Gaia

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

func New

func New(opts ...Option) *Gaia

New create an application lifecycle manager.

func (*Gaia) Endpoint

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

Endpoint returns endpoints.

func (*Gaia) ID

func (a *Gaia) ID() string

ID returns app instance id.

func (*Gaia) Metadata

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

Metadata returns service metadata.

func (*Gaia) Name

func (a *Gaia) Name() string

Name returns service name.

func (*Gaia) Run

func (a *Gaia) Run() error

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

func (*Gaia) Stop

func (a *Gaia) Stop() error

Stop gracefully stops the application.

func (*Gaia) Version

func (a *Gaia) Version() string

Version returns app version.

type Option

type Option func(o *options)

Option is an application option.

func WithContext

func WithContext(ctx context.Context) Option

WithContext with a context

func WithEndpoint

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

WithEndpoint with service endpoint.

func WithID

func WithID(id string) Option

WithID with app id

func WithLogger

func WithLogger(logger log.Logger) Option

WithLogger .

func WithMetadata

func WithMetadata(md map[string]string) Option

WithMetadata with service metadata.

func WithName

func WithName(name string) Option

WithName .

func WithRegistry

func WithRegistry(r registry.Registry) Option

WithRegistry with service registry.

func WithRegistryTimeout

func WithRegistryTimeout(t time.Duration) Option

WithRegistryTimeout with registrar timeout.

func WithServer

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

WithServer with a server , http or grpc

func WithSignal

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

WithSignal with some system signal

func WithStopTimeout

func WithStopTimeout(t time.Duration) Option

WithStopTimeout with app stop timeout.

func WithVersion

func WithVersion(version string) Option

WithVersion with a version

Directories

Path Synopsis
cmd
gaia Module
gob
proto
Package proto defines the protobuf codec.
Package proto defines the protobuf codec.
pkg module
plugins
registry/etcd Module
registry/k8s Module

Jump to

Keyboard shortcuts

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