traceable_context

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2020 License: MIT Imports: 3 Imported by: 8 modules, 13 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

Traceable Context

Traceable Context is a wrapper around go context which will provide a way to share a traceable UUID between different contexts

  • New context
package main

import (
    "github.com/google/uuid"
    "github.com/tryfix/traceable-context"
)

func main() {
 ctx := traceable_context.WithUUID(uuid.New())
}
    
  • Context from a parent context
    parent := contect.Background()
    ctx := traceable_context.WithUUID(parent, uuid.New())

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Background

func Background() context.Context

func FromContext

func FromContext(ctx context.Context) uuid.UUID

FromContext extracts the UUID from a given context

Types

type TraceableContext

type TraceableContext interface {
	context.Context
	// UUID returns the uuid inside the context
	UUID() uuid.UUID
}

TraceableContext wrap the go context with a traceable uuid

func FromContextWithUUID

func FromContextWithUUID(parent context.Context, uuid uuid.UUID) TraceableContext

FromContextWithUUID creates a new traceable context from a given parent context and a UUID

func WithCancel

func WithCancel(parent context.Context) (ctx TraceableContext, cancel context.CancelFunc)

func WithDeadline

func WithDeadline(parent context.Context, deadline time.Time) (ctx TraceableContext, cancel context.CancelFunc)

func WithTimeout

func WithTimeout(parent context.Context, timeout time.Duration) (ctx TraceableContext, cancel context.CancelFunc)

func WithUUID

func WithUUID(uuid uuid.UUID) TraceableContext

WithUUID creates a new traceable context from a given UUID

func WithValue

func WithValue(parent context.Context, key, val interface{}) TraceableContext

Jump to

Keyboard shortcuts

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