xtransport

package module
v0.0.0-...-4506884 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2024 License: MIT Imports: 4 Imported by: 0

README

Xtransport

Build Status License Coverage Status Goreportcard Go Reference


Package xtransport provides a transport layer for go. Currently http transport is implemented.

Installation
$ go get github.com/actforgood/xtransport
NOTE

This package is currently under development and is unstable. APIs may change. If you want to use it it's on your own risk. We recommend to wait for a stable release!

Documentation

Overview

Package xtransport provides transport related utilities.

Index

Constants

This section is empty.

Variables

View Source
var CorrelationIDHeaderKey = "X-Correlation-Id"

CorrelationIDHeaderKey is the header to look for correlation id.

Functions

func ContextWithCorrelationID

func ContextWithCorrelationID(ctx context.Context, correlationID string) context.Context

ContextWithCorrelationID returns a new context enriched with correlation id information.

func CorrelationIDFromContext

func CorrelationIDFromContext(ctx context.Context) string

CorrelationIDFromContext returns the correlation id stored in the context, or an empty value if no correlation id is present in the context.

Types

type CorrelationIDFactory

type CorrelationIDFactory func() string

CorrelationIDFactory generates correlation ids.

var UUIDCorrelationIDFactory CorrelationIDFactory = uuid.NewString

UUIDCorrelationIDFactory is a CorrelationIDFactory that produces UUID based correlation ids.

var XRandCorrelationIDFactory CorrelationIDFactory = func() string { return xrand.String(32) }

XRandCorrelationIDFactory is a CorrelationIDFactory that produces random alfanumeric strings of length 32.

type Probe

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

Probe can be used as a ready/alive/health flag. It is concurrent safe to use.

func (*Probe) IsReady

func (p *Probe) IsReady() bool

IsReady returns probe readiness.

func (*Probe) SetReady

func (p *Probe) SetReady(isReady bool)

SetReady sets the readiness state.

type Transport

type Transport interface {
	// StartAsync starts the transport asynchronous.
	// Any error received is passed to the error channel passed as second parameter.
	StartAsync(context.Context, chan<- error)

	// Shutdown stops the transport.
	Shutdown(context.Context) error
}

Transport is the contract for a transport.

Directories

Path Synopsis
Package decoder provides decoding utilities.
Package decoder provides decoding utilities.
Package http provides a HTTP transport and some utitities.
Package http provides a HTTP transport and some utitities.
middleware
Package middleware provides HTTP handler useful decorators.
Package middleware provides HTTP handler useful decorators.
testing
assert
Package assert provides basic assertion utilities.
Package assert provides basic assertion utilities.

Jump to

Keyboard shortcuts

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