kratosx

package
v0.0.0-...-734a412 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 45 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AppName    = "APP_NAME"
	AppVersion = "APP_VERSION"
)
View Source
const Release = "v1.0.5"

Release is the current resource version.

Variables

This section is empty.

Functions

func New

func New(opts ...Option) *kratos.App

Types

type Context

type Context interface {
	Env() string
	Logger() *log.Helper
	DB(name ...string) *gorm.DB
	Transaction(fn func(ctx Context) error, name ...string) error
	Redis(name ...string) *redis.Client
	Go(runner pool.Runner) error
	Loader(name string) []byte
	Email() email.Email
	ClientIP() string
	Captcha() captcha.Captcha
	JWT() jwt.Jwt
	Token() string
	Authentication() authentication.Authentication
	Ctx() context.Context
	GetMetadata(string) string
	SetMetadata(key, value string)
	WaitRunner() pool.WaitRunner
	Http() http.Request
	GrpcConn(srvName string) (*grpc.ClientConn, error)

	ID() string
	Name() string
	Version() string
	Metadata() map[string]string
	Config() config.Config
	Endpoint() []string

	Clone() Context
	Deadline() (deadline time.Time, ok bool)
	Done() <-chan struct{}
	Err() error
	Value(key any) any
}

func MustContext

func MustContext(c context.Context, opts ...ContextOptionFunc) Context

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

type ContextOption

type ContextOption struct {
	Trace string
	Span  string
}

type ContextOptionFunc

type ContextOptionFunc func(*ContextOption)

func WithTrace

func WithTrace(trace string, span string) ContextOptionFunc

WithTrace 主动设置trace信息

type Option

type Option func(o *options)

func Config

func Config(source kratosConfig.Source) Option

Config 配置接入

func GrpcServerOptions

func GrpcServerOptions(opts ...grpc.ServerOption) Option

GrpcServerOptions grpc server option

func HttpServerOptions

func HttpServerOptions(opts ...http.ServerOption) Option

HttpServerOptions http server option

func LoggerWith

func LoggerWith(fields logger.LogField) Option

LoggerWith 自定义字段

func MiddlewareOptions

func MiddlewareOptions(opts ...middleware.Middleware) Option

MiddlewareOptions middleware option

func Options

func Options(opts ...kratos.Option) Option

Options kratos option

func RegistrarServer

func RegistrarServer(fn RegistrarServerFn) Option

RegistrarServer 服务注册

type RegistrarServerFn

type RegistrarServerFn func(config config.Config, hs *http.Server, gs *grpc.Server)

Jump to

Keyboard shortcuts

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