sarama.go 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. Package sarama provides client libraries for the Kafka 0.8 protocol. The AsyncProducer object is the high-level
  3. API for producing messages asynchronously; the SyncProducer provides a blocking API for the same purpose.
  4. The Consumer object is the high-level API for consuming messages. The Client object provides metadata
  5. management functionality that is shared between the higher-level objects.
  6. For lower-level needs, the Broker and Request/Response objects permit precise control over each connection
  7. and message sent on the wire.
  8. The Request/Response objects and properties are mostly undocumented, as they line up exactly with the
  9. protocol fields documented by Kafka at https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol
  10. */
  11. package sarama
  12. import (
  13. "io/ioutil"
  14. "log"
  15. )
  16. // Logger is the instance of a StdLogger interface that Sarama writes connection
  17. // management events to. By default it is set to discard all log messages via ioutil.Discard,
  18. // but you can set it to redirect wherever you want.
  19. var Logger StdLogger = log.New(ioutil.Discard, "[Sarama] ", log.LstdFlags)
  20. // StdLogger is used to log error messages.
  21. type StdLogger interface {
  22. Print(v ...interface{})
  23. Printf(format string, v ...interface{})
  24. Println(v ...interface{})
  25. }
  26. // PanicHandler is called for recovering from panics spawned internally to the library (and thus
  27. // not recoverable by the caller's goroutine). Defaults to nil, which means panics are not recovered.
  28. var PanicHandler func(interface{})
  29. // MaxRequestSize is the maximum size (in bytes) of any request that Sarama will attempt to send. Trying
  30. // to send a request larger than this will result in an PacketEncodingError. The default of 100 MiB is aligned
  31. // with Kafka's default `socket.request.max.bytes`, which is the largest request the broker will attempt
  32. // to process.
  33. var MaxRequestSize int32 = 100 * 1024 * 1024
  34. // MaxResponseSize is the maximum size (in bytes) of any response that Sarama will attempt to parse. If
  35. // a broker returns a response message larger than this value, Sarama will return a PacketDecodingError to
  36. // protect the client from running out of memory. Please note that brokers do not have any natural limit on
  37. // the size of responses they send. In particular, they can send arbitrarily large fetch responses to consumers
  38. // (see https://issues.apache.org/jira/browse/KAFKA-2063).
  39. var MaxResponseSize int32 = 100 * 1024 * 1024