core

package
v1.5.8 Latest Latest
Warning

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

Go to latest
Published: May 12, 2022 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetContext

func GetContext(c *gin.Context, name string) (interface{}, error)

GetContext get custom context

func GetRequest

func GetRequest(c *gin.Context) *req

GetRequest get request datatype from context

func GetSpan

func GetSpan(c *gin.Context) opentracing.Span

GetSpan get opentracing span from context

func SetContext

func SetContext(c *gin.Context, name string, val interface{})

SetContext set custom context

func StartSpanFormRpc

func StartSpanFormRpc(ctx context.Context, operateName string) opentracing.Span

StartSpanFormRpc start and get opentracing span from rpc call

func StartSpanFromHeader

func StartSpanFromHeader(header http.Header, operateName string) opentracing.Span

StartSpanFromHeader Get the opentracing span from the request header If no span, will create new root span, if any, new child span

func StartSpanFromTextMap

func StartSpanFromTextMap(textMap opentracing.TextMapCarrier, operateName string) opentracing.Span

StartSpanFromTextMap Get the opentracing span from textMap If no span, will create new root span, if any, new child span

Types

type Garden

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

Garden go garden framework class

func New

func New() *Garden

New create go-garden instance

func (*Garden) CallRpc

func (g *Garden) CallRpc(span opentracing.Span, service, action string, args, reply interface{}) error

CallRpc call other service rpc method

func (*Garden) CheckCallSafeMiddleware

func (g *Garden) CheckCallSafeMiddleware() gin.HandlerFunc

CheckCallSafeMiddleware from call service safe check

func (*Garden) FinishRpcTrace

func (g *Garden) FinishRpcTrace(span opentracing.Span)

FinishRpcTrace rpc method use this method last

func (*Garden) GatewayRoute

func (g *Garden) GatewayRoute(r *gin.Engine)

GatewayRoute create gateway service type to use this

func (*Garden) Get

func (g *Garden) Get(name string) (interface{}, error)

Get instance by name

func (*Garden) GetCfg

func (g *Garden) GetCfg() cfg

func (*Garden) GetEtcd

func (g *Garden) GetEtcd() (*clientV3.Client, error)

GetEtcd instance to performing etcd operations

func (*Garden) GetServiceId

func (g *Garden) GetServiceId() string

GetServiceId get this service union id

func (*Garden) GetServiceIp

func (g *Garden) GetServiceIp() string

GetServiceIp get this service ip

func (*Garden) GetServices

func (g *Garden) GetServices() map[string]*service

GetServices get all cluster service map by etcdKey

func (*Garden) PushGateway

func (g *Garden) PushGateway(job string, data MapData) (string, error)

PushGateway upload metric to pushGateway

func (*Garden) Run

func (g *Garden) Run(route func(r *gin.Engine), rpc interface{}, auth func() gin.HandlerFunc)

Run service start

func (*Garden) Set

func (g *Garden) Set(name string, val interface{}) error

Set instance by name, not support default name like 'etcd'

func (*Garden) SetMetric

func (g *Garden) SetMetric(key string, val interface{})

SetMetric to prometheus collect

func (*Garden) StartRpcTrace

func (g *Garden) StartRpcTrace(ctx context.Context, args interface{}, method string) opentracing.Span

StartRpcTrace rpc method use this method first

type MapData

type MapData map[string]interface{}

MapData map like any value datatype

type Rpc

type Rpc int

func (*Rpc) SyncRoutes

func (r *Rpc) SyncRoutes(ctx context.Context, args *SyncRoutesArgs, reply *SyncRoutesReply) error

SyncRoutes sync routes.yml method

type SyncRoutesArgs

type SyncRoutesArgs struct {
	Yml []byte
}

type SyncRoutesReply

type SyncRoutesReply struct {
	Result bool
}

Directories

Path Synopsis
drives

Jump to

Keyboard shortcuts

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