Consume Kafka Protobuf Messages on Command Line

I have kafka messages defined in protobuf. I want to easily consume the messages. Kafka has a default command line tool called kafka-console-consumer. It has --value-deserializer. If I have a Java deserializer which deserializes kafka messages in protobuf, it should work. However, firstly I don’t want to write extra code. Secondly, --value-deserializer does not work (https://stackoverflow.com/questions/45581082/kafka-console-consumer-sh-custom-deserializer). Confluent has a Schema Registry which allows you to save message schema. However, as of now it supports Avro only. [Read More]

Test Coverage with Integration Tests in go

Basics go test tests packages as it is stated below. > go test -h test [build/test flags] [packages] [build/test flags & test binary flags] So given a package, go test runs both in package tests and outside package tests. > go test github.com/haibin/coverage/person ok github.com/haibin/coverage/person 0.007s To list in package tests, run the following. > go list -f '{{.TestGoFiles}}' github.com/haibin/coverage/person [foo_test.go] To list outside package tests, run the following. [Read More]

tcpKeepAliveListener in go

We can quickly start a http server in go as below. http.ListenAndServe(":8080", nil) It is called ListenAndServe because it creates a TCP listener and passes it to the http server. ln, err := net.Listen("tcp", addr) srv.Serve(ln) The actual implementation in the go standard library uses a tcpKeepAliveListener which wraps the TCP listener. srv.Serve(tcpKeepAliveListener{ln.(*net.TCPListener)}) tcpKeepAliveListener implements the TCP keep-alives which might not be very important because HTTP keep-alives are enabled by default. [Read More]

Use Different Git Emails for Different Repositories

Sometimes we make mistake by using personal email in the git commit for company repositories or vice versa. To fix this issue, use user.useConfigOnly. user.useConfigOnly Instruct Git to avoid trying to guess defaults for user.email and user.name, and instead retrieve the values only from the configuration. For example, if you have multiple email addresses and would like to use a different one for each repository, then with this configuration option set to true in the global config along with a name, Git will prompt you to set up an email before making new commits in a newly cloned repository. [Read More]