Documentation ¶
Index ¶
- Constants
- Variables
- func NewLoggingConfig() *logging.Config
- func NewProvisionerLoggerFromConfig(config *logging.Config) *zap.SugaredLogger
- type ChannelReference
- type DispatchDefaults
- type Dispatcher
- type Message
- type MessageDispatcher
- type MessageReceiver
- type ReceiverOptions
- type ResolveChannelFromHostFunc
Constants ¶
const ( // MessageHistoryHeader is the header containing all channel hosts traversed by the message // This is an experimental header: https://github.com/knative/eventing/issues/638 MessageHistoryHeader = "ce-knativehistory" MessageHistorySeparator = "; " )
const (
// MessageReceiverPort is the port that MessageReceiver opens an HTTP server on.
MessageReceiverPort = 8080
)
Variables ¶
var ErrUnknownChannel = errors.New("unknown channel")
ErrUnknownChannel is returned when a message is received by a channel dispatcher for a channel that does not exist.
Functions ¶
func NewLoggingConfig ¶
NewLoggingConfig creates a static logging configuration appropriate for a provisioner. All logging levels are set to Info.
func NewProvisionerLoggerFromConfig ¶
func NewProvisionerLoggerFromConfig(config *logging.Config) *zap.SugaredLogger
NewProvisionerLoggerFromConfig creates a new zap logger for the provisioner component based on the provided configuration
Types ¶
type ChannelReference ¶
ChannelReference references a Channel within the cluster by name and namespace.
func ParseChannel ¶
func ParseChannel(host string) (ChannelReference, error)
ParseChannel converts the channel's hostname into a channel reference.
func (*ChannelReference) String ¶
func (r *ChannelReference) String() string
type DispatchDefaults ¶
type DispatchDefaults struct {
Namespace string
}
DispatchDefaults provides default parameter values used when dispatching a message.
type Dispatcher ¶
type Dispatcher interface { // DispatchMessage dispatches a message to a destination over HTTP. // // The destination and reply are DNS names. For names with a single label, // the default namespace is used to expand it into a fully qualified name // within the cluster. DispatchMessage(message *Message, destination, reply string, defaults DispatchDefaults) error }
type Message ¶
type Message struct { // Headers provide metadata about the message payload. All header keys // should be lowercase. Headers map[string]string `json:"headers,omitempty"` // Payload is the raw binary content of the message. The payload format is // often described by the 'content-type' header. Payload []byte `json:"payload,omitempty"` }
Message represents a chunk of data within a channel dispatcher. The message contains both a map of string headers and a binary payload. This struct gets marshaled/unmarshaled in order to preserve and pass Header information to the event subscriber.
A message may represent a CloudEvent.
func (*Message) AppendToHistory ¶
AppendToHistory appends a new host at the end of the list of hosts of the message history
type MessageDispatcher ¶
type MessageDispatcher struct {
// contains filtered or unexported fields
}
MessageDispatcher dispatches messages to a destination over HTTP.
func NewMessageDispatcher ¶
func NewMessageDispatcher(logger *zap.SugaredLogger) *MessageDispatcher
NewMessageDispatcher creates a new message dispatcher that can dispatch messages to HTTP destinations.
func (*MessageDispatcher) DispatchMessage ¶
func (d *MessageDispatcher) DispatchMessage(message *Message, destination, reply string, defaults DispatchDefaults) error
DispatchMessage dispatches a message to a destination over HTTP.
The destination and reply are DNS names. For names with a single label, the default namespace is used to expand it into a fully qualified name within the cluster.
type MessageReceiver ¶
type MessageReceiver struct {
// contains filtered or unexported fields
}
MessageReceiver starts a server to receive new messages for the channel dispatcher. The new message is emitted via the receiver function.
func NewMessageReceiver ¶
func NewMessageReceiver(receiverFunc func(ChannelReference, *Message) error, logger *zap.SugaredLogger, opts ...ReceiverOptions) (*MessageReceiver, error)
NewMessageReceiver creates a message receiver passing new messages to the receiverFunc.
func (*MessageReceiver) HandleRequest ¶
func (r *MessageReceiver) HandleRequest(res http.ResponseWriter, req *http.Request)
HandleRequest is an http.Handler function. The request is converted to a Message and emitted to the receiver func.
The response status codes:
202 - the message was sent to subscribers 404 - the request was for an unknown channel 500 - an error occurred processing the request
func (*MessageReceiver) Start ¶
func (r *MessageReceiver) Start(stopCh <-chan struct{}) error
Start begings to receive messages for the receiver.
Only HTTP POST requests to the root path (/) are accepted. If other paths or methods are needed, use the HandleRequest method directly with another HTTP server.
This method will block until a message is received on the stop channel.
type ReceiverOptions ¶
type ReceiverOptions func(*MessageReceiver) error
ReceiverOptions provides functional options to MessageReceiver function.
func ResolveChannelFromHostHeader ¶
func ResolveChannelFromHostHeader(hostToChannelFunc ResolveChannelFromHostFunc) ReceiverOptions
ResolveChannelFromHostHeader is a ReceiverOption for NewMessageReceiver which enables the caller to overwrite the default behaviour defined by ParseChannel function.
type ResolveChannelFromHostFunc ¶
type ResolveChannelFromHostFunc func(string) (ChannelReference, error)
ResolveChannelFromHostFunc function enables MessageReceiver to get the Channel Reference from incoming request HostHeader before calling receiverFunc.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package fanout provides an http.Handler that takes in one request and fans it out to N other requests, based on a list of Subscriptions.
|
Package fanout provides an http.Handler that takes in one request and fans it out to N other requests, based on a list of Subscriptions. |
Package multichannelfanout provides an http.Handler that takes in one request to a Knative Channel and fans it out to N other requests.
|
Package multichannelfanout provides an http.Handler that takes in one request to a Knative Channel and fans it out to N other requests. |
Package swappable provides an http.Handler that delegates all HTTP requests to an underlying multichannelfanout.Handler.
|
Package swappable provides an http.Handler that delegates all HTTP requests to an underlying multichannelfanout.Handler. |