rushgo

package module
v0.0.0-...-9eed78a Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: MIT Imports: 13 Imported by: 0

README

简体中文

rushgo

inspired by go-kratos, which is the ultimate Go microservices framework for the cloud-native era.

This is a component library that transforms go-kratos to suit my own needs. On one hand, it is for learning the approach of go-kratos, and on the other hand, it is to streamline some aspects of go-kratos that I might not need.

I'm highly recommend you to visit the original repository go-kratos, my implementation may not suit to everyone.

Difference from go-kratos

Transporter
  • transport/http is based on the gorilla/mux HTTP routing framework to implement Transporter in go-kratos, I change the implementation based on Gin Web Framework which I used in general.
  • I didn't write the Client-side implementation in both transport/grpc and transport/http, because I write mostly the Server-side program, so I decide not present the Client-side implementation temporary.

Documentation

Index

Constants

View Source
const Release = "v1.0.0" // Release is the current rushgo version.

Variables

This section is empty.

Functions

func NewContext

func NewContext(ctx context.Context, a Application) context.Context

NewContext returns a new Context that carries value

Types

type App

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

App is an application component's lifecycle manager.

func New

func New(opts ...Option) *App

func (*App) Endpoint

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

func (*App) ID

func (a *App) ID() string

func (*App) Metadata

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

func (*App) Name

func (a *App) Name() string

func (*App) Run

func (a *App) Run() (err error)

func (*App) Stop

func (a *App) Stop() (err error)

func (*App) Version

func (a *App) Version() string

type Application

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

func FromContext

func FromContext(ctx context.Context) (a Application, ok bool)

FromContext returns the Transport value stored in ctx, if any

type Option

type Option func(*options)

func AfterStart

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

func AfterStop

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

func BeforeStart

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

func BeforeStop

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

func Context

func Context(ctx context.Context) Option

func Endpoints

func Endpoints(ep ...*url.URL) Option

func ID

func ID(id string) Option

func Logger

func Logger(l log.Logger) Option

func Metadata

func Metadata(md map[string]string) Option

func Name

func Name(name string) Option

func Registrar

func Registrar(r registry.Registrar) Option

func RegistrarTimeout

func RegistrarTimeout(t time.Duration) Option

func Servers

func Servers(svr ...transport.Server) Option

func Signal

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

func StopTimeout

func StopTimeout(t time.Duration) Option

func Version

func Version(version string) Option

Directories

Path Synopsis
env
contrib
registry/kubernetes
Package kuberegister registry simply implements the kubernetes-base Registry
Package kuberegister registry simply implements the kubernetes-base Registry
xml
internal
trace/grpc_trace
Package grpc_trace
Package grpc_trace

Jump to

Keyboard shortcuts

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