Documentation ¶
Index ¶
- Variables
- type Config
- type Context
- func (ctx *Context) Deadline() (deadline time.Time, ok bool)
- func (ctx *Context) Done() <-chan struct{}
- func (ctx *Context) Err() error
- func (c *Context) Header() *protocol.RequestHeader
- func (ctx *Context) Request() interface{}
- func (ctx *Context) Response() interface{}
- func (ctx *Context) String() string
- func (ctx *Context) Value(key interface{}) interface{}
- type Handler
- type MessageProvider
- type Server
Constants ¶
This section is empty.
Variables ¶
var ClusterID = "dekafclusterid"
ClusterID we will use when talking to clients.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // The Host we should tell Kafka clients to connect to. Host string // The Port we should tell Kafka clients to connect to. Port int32 // The maximum number of messages we will provide per topic. // Defaults to 10 if not set. MaxMessagesPerTopic int // How long to wait for messages from the provider. // The config value will take precedence followed by the client request time // and finally if neither are set, will default to 5 seconds. MessageWaitDeadline time.Duration // Debug dumps message request/response. Debug bool }
Config defines the handler config
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Context holds a Kafka request/response pair for processing.
func (*Context) Header ¶
func (c *Context) Header() *protocol.RequestHeader
type Handler ¶
Handler configuration.
func NewHandler ¶
func (*Handler) AddTopic ¶
func (h *Handler) AddTopic(name string, mp MessageProvider)
AddTopic adds a new topic to the server and registers the MessageProvider with that topic.
type MessageProvider ¶
A MessageProvider function is used to provide messages for a topic. The handler will request a message at startOffset. The MessageProvider should return a message offset, payload and error to the request. If there are no more messages return io.EOF for the error. This function may block up until the provided context.Context cancels in which case it should return io.EOF.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is used to handle the TCP connections, decode requests, defer to the handler, and encode the responses.