
This commit includes updates that affects the build, testing, and deployment of Tile38. - The root level build.sh has been broken up into multiple scripts and placed in the "scripts" directory. - The vendor directory has been updated to follow the Go modules rules, thus `make` should work on isolated environments. Also some vendored packages may have been updated to a later version, if needed. - The Makefile has been updated to allow for making single binaries such as `make tile38-server`. There is some scaffolding during the build process, so from now on all binaries should be made using make. For example, to run a development version of the tile38-cli binary, do this: make tile38-cli && ./tile38-cli not this: go run cmd/tile38-cli/main.go - Travis.CI docker push script has been updated to address a change to Docker's JSON repo meta output, which in turn fixes a bug where new Tile38 versions were not being properly pushed to Docker
51 lines
1.8 KiB
Go
51 lines
1.8 KiB
Go
package sarama
|
|
|
|
import "github.com/rcrowley/go-metrics"
|
|
|
|
// PacketEncoder is the interface providing helpers for writing with Kafka's encoding rules.
|
|
// Types implementing Encoder only need to worry about calling methods like PutString,
|
|
// not about how a string is represented in Kafka.
|
|
type packetEncoder interface {
|
|
// Primitives
|
|
putInt8(in int8)
|
|
putInt16(in int16)
|
|
putInt32(in int32)
|
|
putInt64(in int64)
|
|
putArrayLength(in int) error
|
|
|
|
// Collections
|
|
putBytes(in []byte) error
|
|
putRawBytes(in []byte) error
|
|
putString(in string) error
|
|
putStringArray(in []string) error
|
|
putInt32Array(in []int32) error
|
|
putInt64Array(in []int64) error
|
|
|
|
// Provide the current offset to record the batch size metric
|
|
offset() int
|
|
|
|
// Stacks, see PushEncoder
|
|
push(in pushEncoder)
|
|
pop() error
|
|
|
|
// To record metrics when provided
|
|
metricRegistry() metrics.Registry
|
|
}
|
|
|
|
// PushEncoder is the interface for encoding fields like CRCs and lengths where the value
|
|
// of the field depends on what is encoded after it in the packet. Start them with PacketEncoder.Push() where
|
|
// the actual value is located in the packet, then PacketEncoder.Pop() them when all the bytes they
|
|
// depend upon have been written.
|
|
type pushEncoder interface {
|
|
// Saves the offset into the input buffer as the location to actually write the calculated value when able.
|
|
saveOffset(in int)
|
|
|
|
// Returns the length of data to reserve for the output of this encoder (eg 4 bytes for a CRC32).
|
|
reserveLength() int
|
|
|
|
// Indicates that all required data is now available to calculate and write the field.
|
|
// SaveOffset is guaranteed to have been called first. The implementation should write ReserveLength() bytes
|
|
// of data to the saved offset, based on the data between the saved offset and curOffset.
|
|
run(curOffset int, buf []byte) error
|
|
}
|