gtool

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddMetaData

func AddMetaData(ctx context.Context, key string, val string) context.Context

func GetMetaData

func GetMetaData(ctx context.Context, key string) (string, error)

func HttpGet

func HttpGet(ctx context.Context, url string) (*http.Response, error)

func HttpHead

func HttpHead(ctx context.Context, url string) (*http.Response, error)

func HttpPost

func HttpPost(ctx context.Context, url string, bodyType string, body io.Reader) (*http.Response, error)

func StartSpan

func StartSpan(ctx context.Context, name, spanType string) (*apm.Span, context.Context)

example:

span, printCtx := gtool.StartSpan(ctx, "print article", "print.query")
defer span.End()
...

Start a span by transaction.

func WithAPMContext

func WithAPMContext(ctx context.Context) context.Context

func WithGrpcContext

func WithGrpcContext(ctx context.Context) context.Context

func WithOrmContext

func WithOrmContext(ctx context.Context, db *gorm.DB) *gorm.DB

func WithRedigoContext

func WithRedigoContext(redisPool *redis.Pool, ctx context.Context) redis.Conn

Types

type Conn

type Conn struct {
	ServerName string
	ServerPort uint64

	CertFile       string
	CertServerName string
}

func NewConn

func NewConn(serviceName string) *Conn

func (*Conn) GetAPMConn

func (c *Conn) GetAPMConn(ctx context.Context) (*grpc.ClientConn, error)

func (*Conn) GetClientConn

func (c *Conn) GetClientConn() (*grpc.ClientConn, error)

type TracingClient

type TracingClient struct {
	HttpClient *http.Client
}

func (*TracingClient) HttpDo

func (t *TracingClient) HttpDo(ctx context.Context, r *http.Request) (*http.Response, error)

func (*TracingClient) HttpGet

func (t *TracingClient) HttpGet(ctx context.Context, url string) (*http.Response, error)

func (*TracingClient) HttpHead

func (t *TracingClient) HttpHead(ctx context.Context, url string) (*http.Response, error)

func (*TracingClient) HttpPost

func (t *TracingClient) HttpPost(ctx context.Context, url string, bodyType string, body io.Reader) (*http.Response, error)

type TracingClientIface

type TracingClientIface interface {
	HttpGet(ctx context.Context, url string) (*http.Response, error)
	HttpPost(ctx context.Context, url string, bodyType string, body io.Reader) (*http.Response, error)
	HttpHead(ctx context.Context, url string) (*http.Response, error)
	HttpDo(ctx context.Context, r *http.Request) (*http.Response, error)
}

func NewTracingClient

func NewTracingClient(client *http.Client) TracingClientIface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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