server

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2021 License: MIT Imports: 5 Imported by: 14

Documentation

Overview

Package server provides ...

Package server provides ...

Index

Constants

View Source
const (
	// recover from panic
	FlagRecover = 1 << iota
	// tracing with opentelemetry
	FlagTracing
	// metric
	FlagMetric
	// client secure for tls
	FlagSecure

	ServerStdFlag = FlagRecover
	ClientStdFlag = 0
)

flag list

Variables

This section is empty.

Functions

This section is empty.

Types

type DialOption

type DialOption func(opts *DialOptions)

DialOption client dial option

func WithCliFlag

func WithCliFlag(flags ...FlagOption) DialOption

WithCliFlag client flag

func WithContext

func WithContext(ctx context.Context) DialOption

WithContext client context

func WithEndpoint

func WithEndpoint(addr string) DialOption

WithEndpoint connect to server endpoint

func WithRegistry

func WithRegistry(reg registry.Registry) DialOption

WithRegistry registry for discovery

func WithTimeout

func WithTimeout(timeout time.Duration) DialOption

WithTimeout dial timeout

func WithUserAgent

func WithUserAgent(ua string) DialOption

WithUserAgent client user-agent

type DialOptions

type DialOptions struct {
	// client connect to endpoint
	Endpoint string
	// connect timeout
	Timeout time.Duration
	// user-agent
	UserAgent string
	// other options for implementations of the interface
	// can be stored in a context
	Context context.Context

	// discovery registry to server
	Registry registry.Registry
	// client flag
	Flag FlagOption
}

DialOptions client dial Options

type FlagOption

type FlagOption int

FlagOption to flag with 0/1

type Server

type Server interface {
	Start() error
	Stop() error
	Endpoint() (string, error)
}

Server micro server

type ServerOption

type ServerOption func(opts *ServerOptions)

ServerOption server option

func WithAddress

func WithAddress(addr string) ServerOption

WithAddress server endpoint

func WithHandler

func WithHandler(h http.Handler) ServerOption

WithHandler server handler

func WithNetwork

func WithNetwork(network string) ServerOption

WithNetwork server network

func WithOptions

func WithOptions(sopts ...grpc.ServerOption) ServerOption

WithOptions gRPC server option

func WithSrvFlag

func WithSrvFlag(flags ...FlagOption) ServerOption

WithSrvFlag server flag

type ServerOptions

type ServerOptions struct {
	// server listen network tcp/udp
	Network string
	// server run address
	Address string
	// handler for http server
	Handler http.Handler
	// Options for gRPC server
	Options []grpc.ServerOption

	// server flag
	Flag FlagOption
}

ServerOptions server Options

Directories

Path Synopsis
Package grpcx provides ...
Package grpcx provides ...
clientinterceptor
Package clientinterceptor provides ...
Package clientinterceptor provides ...
resolver
Package resolver provides ...
Package resolver provides ...
serverinterceptor
Package serverinterceptor provides ...
Package serverinterceptor provides ...
Package httpx provides ...
Package httpx provides ...
handler
Package handler provides ...
Package handler provides ...

Jump to

Keyboard shortcuts

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