1

This is the working JavaScript version of what I'm trying to do in Go.

let next = TBufferedTransport.receiver(data => {

 let proto = new TCompactProtocol(data)
 let ae = new AnalyticEventBatch()

 ae.read(proto)
});

Using Go, I can't get Thrift to decode the payload - what should I be doing?

9
  • Is the payload json? Commented Mar 1, 2016 at 17:39
  • 2
    Also, please post what you've already tried in GO Commented Mar 1, 2016 at 17:39
  • Check out gRPC. grpc.io/faq Commented Mar 1, 2016 at 18:08
  • @OliverQueen no the payload is binary Commented Mar 1, 2016 at 18:20
  • @voutasaurus i'm receiving the data from Kafka - i don't have control over the transport layer Commented Mar 1, 2016 at 18:22

1 Answer 1

4
var data []byte //that's the byte array you received

transp := &TMemoryBuffer{Buffer: bytes.NewBuffer(data)}
proto := NewTCompactProtocol(transp)

ae := NewAnalyticEventBatch()
ae.Read(proto)

It would be cleaner if you could read from file/socket directly. Then you would only need thrift StreamTransport

Sign up to request clarification or add additional context in comments.

1 Comment

You have a small typo: proto := thrift.NewTCompactProtocol(transp), but otherwise this worked perfectly!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.