xservice

package
v1.2.12 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: MIT Imports: 53 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// GrpcClientConn returns a grpc client connection
	GrpcClientConn(ctx context.Context, service string, desc *grpc.ServiceDesc, endpoint ...string) (grpc.ClientConnInterface, error)
}

Client is the client for xservice

type GrpcRegisterHandler

type GrpcRegisterHandler func(ctx context.Context, mux *gwrt.ServeMux, conn *grpc.ClientConn) error

GrpcRegisterHandler is the interface for gRPC service register handler

type Option

type Option func(*Options)

Option for option config

func Build

func Build(build string) Option

Build set build version for service

func Config

func Config(config *viper.Viper) Option

Config set custom viper instance for xservice configuration

Note: default configuration enabled watch feature, if set custom viper, watch feature should implements by you self

func Description

func Description(description string) Option

Description set description for service

func Name

func Name(name string) Option

Name set service name

func Version

func Version(version string) Option

Version set service version

func WithDbConfigureFn added in v1.0.17

func WithDbConfigureFn(fn gormx.ConfigureFn) Option

WithDbConfigureFn set db configure function

func WithEchoTracingSkipper

func WithEchoTracingSkipper(skipper middleware.Skipper) Option

WithEchoTracingSkipper set tracing skipper

func WithGrpcClientDialOptions added in v1.0.11

func WithGrpcClientDialOptions(options ...grpc.DialOption) Option

WithGrpcClientDialOptions add additional grpc client dial options

func WithGrpcClientDialTimeout added in v1.0.12

func WithGrpcClientDialTimeout(timeout time.Duration) Option

WithGrpcClientDialTimeout set client dial timeout default 2 seconds

func WithGrpcServerEnableReflection added in v1.2.0

func WithGrpcServerEnableReflection(enable bool) Option

WithGrpcServerEnableReflection enable reflection for grpc server

func WithGrpcServerOptions added in v1.0.11

func WithGrpcServerOptions(options ...grpc.ServerOption) Option

WithGrpcServerOptions add additional grpc server options

func WithSentry

func WithSentry(options sentry.ClientOptions) Option

WithSentry set sentry option for enable sentry

type Options

type Options struct {
	Name                       string
	Version                    string
	Build                      string
	Description                string
	Config                     *viper.Viper
	DbConfigureFn              gormx.ConfigureFn
	GrpcServerOptions          []grpc.ServerOption
	GrpcServerEnableReflection bool
	GrpcClientDialOptions      []grpc.DialOption
	GrpcClientDialTimeout      time.Duration
	SentryOptions              sentry.ClientOptions
	EchoTracingSkipper         middleware.Skipper
}

Options for xservice core option

type Server

type Server interface {
	// Echo returns the echo instance
	Echo() *echo.Echo

	// Serve start and listen server
	Serve() error

	// GrpcRegister registers a gRPC service
	GrpcRegister(desc *grpc.ServiceDesc, impl interface{}, handler ...GrpcRegisterHandler)
}

Server is the interface for xservice server

type Service

type Service interface {
	Name() string
	Options() *Options
	Client() Client
	Server() Server
	String() string
}

Service is a service interface, core api for xservice

func New

func New(options ...Option) Service

New create new xservice instance

Jump to

Keyboard shortcuts

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