Пример #1
0
func writeRequest(request siesta.Request, connection net.Conn) {
	header := siesta.NewRequestWriter(123, "test-client", request)
	bytes := make([]byte, header.Size())
	encoder := siesta.NewBinaryEncoder(bytes)
	header.Write(encoder)
	fmt.Printf("full request: % x\n", bytes)

	_, err := connection.Write(bytes)
	if err != nil {
		panic(err)
	}
}
Пример #2
0
func main() {
	//	b := make([]byte, 4)
	//	siesta.NewBinaryEncoder(b).WriteInt32(750693)
	//	fmt.Printf("bytes: % x\n", b)

	//	request := siesta.NewTopicMetadataRequest([]string{"logs1"})
	//	request := new(siesta.OffsetRequest)
	//	request.AddPartitionOffsetRequestInfo("test-2", 0, siesta.LatestTime, 1)

	//	request := new(siesta.FetchRequest)
	//	request.AddFetch("test-2", 0, 0, 50)

	//	request := siesta.NewConsumerMetadataRequest("go-consumer-group")

	//	request := siesta.NewOffsetCommitRequest("other-go-group")
	//	request.AddOffset("test-2", 0, 7, 123456789, "h")

	//	request := siesta.NewOffsetFetchRequest("other-go-group")
	//	request.AddOffset("test-2", 0)

	request := new(siesta.ProduceRequest)
	request.RequiredAcks = 1
	request.Timeout = 2000
	request.AddMessage("siesta", 0, &siesta.MessageData{MagicByte: -12, Value: []byte("hello world")})

	sizing := siesta.NewSizingEncoder()
	request.Write(sizing)
	bytes := make([]byte, sizing.Size())
	encoder := siesta.NewBinaryEncoder(bytes)
	request.Write(encoder)
	fmt.Printf("request % x\n", bytes)

	connection := openConnection("localhost:9092")
	writeRequest(request, connection)
	readResponse(connection)
}