forward

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package forward provides a mechanism to forward TChannel requests.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ForwardedHeaderName is the name used by the ringpop adapter to indicate
	// it is a forwarded request.
	ForwardedHeaderName = "ringpop-forward-keys"
)

Functions

func DeleteForwardedHeader added in v0.7.1

func DeleteForwardedHeader(ctx thrift.Context) bool

DeleteForwardedHeader takes the headers that came in via TChannel and looks for the precense of a specific ringpop header to see if ringpop already forwarded the message. If the header is present it will delete the header from the context. The return value indicates if the header was present and deleted

func SetForwardedHeader

func SetForwardedHeader(ctx thrift.Context, keys []string) thrift.Context

SetForwardedHeader adds a header to the current thrift context indicating that the call has been forwarded by another node in the ringpop ring. This header is used when a remote call is received to determine if forwarding checks needs to be applied. By not forwarding already forwarded calls we prevent unbound forwarding in the ring in case of memebership disagreement. The keys provided will be serialized as the value of the key and can be used in the future to check if key inconsistencies are found while forwarding. Currently this is not checked

Types

type FailedEvent

type FailedEvent struct{}

A FailedEvent is emitted when the forwarded request responded with an error

type Forwarder

type Forwarder struct {
	events.AsyncEventEmitter
	// contains filtered or unexported fields
}

A Forwarder is used to forward requests to their destinations

func NewForwarder

func NewForwarder(s Sender, ch shared.SubChannel) *Forwarder

NewForwarder returns a new forwarder

func (*Forwarder) ForwardRequest

func (f *Forwarder) ForwardRequest(request []byte, destination, service, endpoint string,
	keys []string, format tchannel.Format, opts *Options) ([]byte, error)

ForwardRequest forwards a request to the given service and endpoint returns the response. Keys are used by the sender to lookup the destination on retry. If you have multiple keys and their destinations diverge on a retry then the call is aborted.

type InflightCountOperation

type InflightCountOperation string

InflightCountOperation indicates the operation being performed on the inflight counter

const (
	// InflightIncrement indicates that the inflight number was being incremented
	InflightIncrement InflightCountOperation = "increment"

	// InflightDecrement indicates that the inflight number was being decremented
	InflightDecrement InflightCountOperation = "decrement"
)

type InflightRequestsChangedEvent

type InflightRequestsChangedEvent struct {
	Inflight int64
}

A InflightRequestsChangedEvent is emitted everytime the number of inflight requests change

type InflightRequestsMiscountEvent

type InflightRequestsMiscountEvent struct {
	Operation InflightCountOperation
}

A InflightRequestsMiscountEvent is emitted when a miscount happend for the inflight requests

type MaxRetriesEvent

type MaxRetriesEvent struct {
	MaxRetries int
}

A MaxRetriesEvent is emitted when the sender failed to complete the request after the maximum specified amount of retries

type Options

type Options struct {
	Ctx            thrift.Context
	MaxRetries     int
	RerouteRetries bool
	RetrySchedule  []time.Duration
	Timeout        time.Duration
	Headers        []byte
}

Options for the creation of a forwarder

type RequestForwardedEvent

type RequestForwardedEvent struct{}

A RequestForwardedEvent is emitted for every forwarded request

type RerouteEvent

type RerouteEvent struct {
	OldDestination string
	NewDestination string
}

A RerouteEvent is emitted when a forwarded request is being rerouted to a new destination

type RetryAbortEvent

type RetryAbortEvent struct {
	Reason string
}

A RetryAbortEvent is emitted when a retry has been aborted. The reason for abortion is embedded

type RetryAttemptEvent

type RetryAttemptEvent struct{}

A RetryAttemptEvent is emitted when a retry is initiated during forwarding

type RetrySuccessEvent

type RetrySuccessEvent struct {
	NumRetries int
}

A RetrySuccessEvent is emitted after a retry resulted in a successful forwarded request

type Sender

type Sender interface {
	// WhoAmI should return the address of the local sender
	WhoAmI() (string, error)

	// Lookup should return the server the request belongs to
	Lookup(string) (string, error)
}

A Sender is used to route the request to the proper destination, the server returned by Lookup(key)

type SuccessEvent

type SuccessEvent struct{}

A SuccessEvent is emitted when the forwarded request responded without an error

Jump to

Keyboard shortcuts

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