Documentation
¶
Index ¶
- Constants
- Variables
- func ConsoleLogger(args ...string) *zap.SugaredLogger
- func GenerateNewTraceparent(sampled bool) (string, error)
- func GenerateParentId() (string, error)
- func GenerateParentIdRaw() ([]byte, error)
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateTraceId() (string, error)
- func GenerateTraceIdRaw() ([]byte, error)
- func NewContextWithCancel() (Context, Cancel)
- func NewContextWithDeadline(deadline time.Time) (Context, Cancel)
- func ParseTraceparent(traceparent string) (string, string, string, string, error)
- func ParseTraceparentRaw(traceparent string) ([]byte, []byte, []byte, []byte, error)
- func ValidateParentIdValue(parentId []byte) error
- func ValidateTraceIdValue(traceId []byte) error
- type AuthProvider
- type Cache
- type Cancel
- type Client
- type ClientOptions
- type Context
- func (r *Context) AddDeadline(deadline time.Time) Cancel
- func (r *Context) Cancel()
- func (r *Context) CompletionHandler(code int, result interface{})
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Error() error
- func (c *Context) OnCancel() <-chan struct{}
- func (r *Context) Value(key string) interface{}
- func (r *Context) WithValue(key, val interface{})
- type NativeDatabase
- type Pooler
- type PoolingOptions
- type TracedClient
- type TracedNativeTx
- func (t *TracedNativeTx) Commit() error
- func (t *TracedNativeTx) Exec(query string, args ...interface{}) (sql.Result, error)
- func (t *TracedNativeTx) ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
- func (t *TracedNativeTx) Query(query string, args ...interface{}) (*sql.Rows, error)
- func (t *TracedNativeTx) QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
- func (t *TracedNativeTx) QueryRow(query string, args ...interface{}) *sql.Row
- func (t *TracedNativeTx) QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
- func (t *TracedNativeTx) Rollback() error
Constants ¶
View Source
const ( MEMORY_CACHE_TYPE = "Memory" REDIS_CACHE_TYPE = "Redis" )
View Source
const ( INVALID_VALUE_COUNT = "invalid number of values" VERSION_INVALID_LENGTH = "invalid version length" TRACEID_INVALID_LENGTH = "invalid traceid length" PARENTID_INVALID_LENGTH = "invalid parentid length" FLAG_INVALID_LENGTH = "invalid flag length" TRACEID_IS_ZERO = "error traceid value is zero" PARENTID_IS_ZERO = "error parentid value is zero" )
Variables ¶
View Source
var (
Err_KEY_NOT_FOUND = fmt.Errorf("key not found")
)
Functions ¶
func ConsoleLogger ¶
func ConsoleLogger(args ...string) *zap.SugaredLogger
func GenerateNewTraceparent ¶
func GenerateParentId ¶
Counting on go compiler to inline these plsplspls :)
func GenerateParentIdRaw ¶
func GenerateRandomBytes ¶
func GenerateTraceId ¶
func GenerateTraceIdRaw ¶
func NewContextWithCancel ¶
func ParseTraceparent ¶
func ParseTraceparentRaw ¶
func ValidateParentIdValue ¶
func ValidateTraceIdValue ¶
Types ¶
type AuthProvider ¶
type AuthProvider interface {
GetAuthHeader() string
}
type Cache ¶
type Cache interface {
Get(key string) (interface{}, error)
Set(key string, value interface{}) error
SetWithExpiration(key string, value interface{}, expiration time.Duration) error
GetCtx(ctx context.Context, key string) (interface{}, error)
SetCtx(ctx context.Context, key string, value interface{}) error
SetWithExpirationCtx(ctx context.Context, key string, value interface{}, expiration time.Duration) error
Delete(key string) error
DeleteCtx(ctx context.Context, key string) error
Keys(pattern string) ([]string, error)
KeysCtx(ctx context.Context, pattern string) ([]string, error)
WithLogger(l *zap.Logger) Cache
WithTracer(t *tracer.AppInsightsCore) Cache
WithName(name string) Cache
}
func CreateFailedMockCacher ¶
func CreateFailedMockCacher() Cache
func CreateSuccessMockCacher ¶
func CreateSuccessMockCacher() Cache
func InitMemoryCache ¶
func InitRedisCache ¶
type Client ¶
type Client interface {
Get(ctx Context, baseUrl string, query string, opt *ClientOptions, dest interface{}) (int, error)
Put(ctx Context, baseUrl string, query string, opt *ClientOptions, body interface{}, dest interface{}) (int, error)
Del(ctx Context, baseUrl string, query string, opt *ClientOptions, dest interface{}) (int, error)
Post(ctx Context, baseUrl string, query string, opt *ClientOptions, body interface{}, dest interface{}) (int, error)
Patch(ctx Context, baseUrl string, query string, opt *ClientOptions, body interface{}, dest interface{}) (int, error)
// contains filtered or unexported methods
}
func ClientProvider ¶
func ClientProvider() Client
type ClientOptions ¶
type ClientOptions struct {
Authorization string `json:"authorization"`
ContentType string `json:"content_type"`
Query string `json:"query"`
Headers *map[string]string `json:"headers"`
Timeout *time.Time `json:"timeout"`
RequestType string `json:"request_type"`
// contains filtered or unexported fields
}
type Context ¶
type Context struct {
context.Context
Res chan interface{}
Code int
// contains filtered or unexported fields
}
func NewContext ¶
func NewContext() Context
func WrapContext ¶
func (*Context) CompletionHandler ¶
type NativeDatabase ¶
type NativeDatabase interface {
Begin() (*TracedNativeTx, error)
BeginTx(ctx context.Context, opts *sql.TxOptions) (*TracedNativeTx, error)
Close() error
Conn(ctx context.Context) (*sql.Conn, error)
Exec(query string, args ...any) (sql.Result, error)
ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
Ping() error
PingContext(ctx context.Context) error
Prepare(query string) (*sql.Stmt, error)
PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
Query(query string, args ...any) (*sql.Rows, error)
QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
QueryRow(query string, args ...any) *sql.Row
QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
SetConnMaxIdleTime(d time.Duration)
SetConnMaxLifetime(d time.Duration)
Stats() sql.DBStats
WithLogger(l *zap.Logger) NativeDatabase
}
func NativeDatabaseProvider ¶
func NativeDatabaseProvider(Driver string, DSN string) NativeDatabase
func TracedNativeDBWrapper ¶
func TracedNativeDBWrapper( Driver string, DSN string, t *tracer.AppInsightsCore, name string, ) NativeDatabase
type PoolingOptions ¶ added in v0.3.0
type PoolingOptions struct {
PoolSize int
}
type TracedClient ¶
type TracedClient interface {
Get(ctx context.Context, Url string, opt *ClientOptions, dest interface{}) (int, error)
Put(ctx context.Context, Url string, opt *ClientOptions, body interface{}, dest interface{}) (int, error)
Del(ctx context.Context, Url string, opt *ClientOptions, dest interface{}) (int, error)
Post(ctx context.Context, Url string, opt *ClientOptions, body interface{}, dest interface{}) (int, error)
Patch(ctx context.Context, Url string, opt *ClientOptions, body interface{}, dest interface{}) (int, error)
SetAuthHandler(provider AuthProvider)
WithClientName(clientName string) TracedClient
// contains filtered or unexported methods
}
func TracedClientProvider ¶
func TracedClientProvider( t *tracer.AppInsightsCore, l *zap.Logger, ) TracedClient
func TracedClientProviderWithName ¶
func TracedClientProviderWithName( t *tracer.AppInsightsCore, l *zap.Logger, clientName string, ) TracedClient
type TracedNativeTx ¶
func (*TracedNativeTx) Commit ¶
func (t *TracedNativeTx) Commit() error
func (*TracedNativeTx) Exec ¶
func (t *TracedNativeTx) Exec(query string, args ...interface{}) (sql.Result, error)
func (*TracedNativeTx) ExecContext ¶
func (*TracedNativeTx) Query ¶
func (t *TracedNativeTx) Query(query string, args ...interface{}) (*sql.Rows, error)
func (*TracedNativeTx) QueryContext ¶
func (*TracedNativeTx) QueryRow ¶
func (t *TracedNativeTx) QueryRow(query string, args ...interface{}) *sql.Row
func (*TracedNativeTx) QueryRowContext ¶
func (*TracedNativeTx) Rollback ¶
func (t *TracedNativeTx) Rollback() error
Click to show internal directories.
Click to hide internal directories.