pletter alternatives and similar packages
Based on the "Serialization" category.
Alternatively, view pletter alternatives based on common mentions on social networks and blogs.
-
jsoniter
A high-performance 100% compatible drop-in replacement of "encoding/json" -
mapstructure
Go library for decoding generic map values into native Go structures and vice versa. -
go-codec
idiomatic codec and rpc lib for msgpack, cbor, json, etc. msgpack.org[Go] -
csvutil
csvutil provides fast and idiomatic mapping between CSV and Go (golang) values. -
cbor
CBOR codec (RFC 8949) with CBOR tags, Go struct tags (toarray, keyasint, omitempty), float64/32/16, big.Int, and fuzz tested billions of execs. -
go-capnproto
Cap'n Proto library and parser for go. This is go-capnproto-1.0, and does not have rpc. See https://github.com/zombiezen/go-capnproto2 for 2.0 which has rpc and capabilities. -
php_session_decoder
PHP session encoder/decoder written in Go -
structomap
Easily and dynamically generate maps from Go static structures -
bambam
auto-generate capnproto schema from your golang source files. Depends on go-capnproto-1.0 at https://github.com/glycerine/go-capnproto -
bel
Generate TypeScript interfaces from Go structs/interfaces - useful for JSON RPC -
go-serializer
:loop: Serialize any custom type or convert any content to []byte or string, for Go Programming Language -
go-lctree
go-lctree provides a CLI and Go primitives to serialize and deserialize LeetCode binary trees (e.g. "[5,4,7,3,null,2,null,-1,null,9]"). -
unitpacking
A library for storing unit vectors in a representation that lends itself to saving space on disk. -
Durations
Go Durations easly parse string durations with no order and high durations like 1 year.
Clean code begins in your IDE with SonarLint
Do you think we are missing an alternative of pletter or a related project?
README
Welcome to Pletter ๐
A standard way to wrap a proto message
Pletter was born with a single mission: To standardize wrapping protocol buffer messages
. This is normally needed when you use protobuf as your messaging protocol.
The Problem
Imagine that you have an event driven architecture. In this system you chose to use protocol buffers to ensure message contract and to transit information.
Let's assume we use Kafka as our message broker. In this Kafka we have one topic called accounts
, this means all account messages will go to the accounts
topic.
On the consumer side, we will receive multiple messages in the same topic. If an application wants to read this messages it needs to identify the message type/name to either enrich, fan out or handle it. To solve that we have a few options:
- If you use something like AMQP instead of a message broker you can set the name of the message in the header and deal with it in the consumer side
- If you use Kafka/Kinesis or any message broker that streams messages, you will need to envelop the message.
Option 2 is the option that Pletter tries to solve in Go.
An interesting article about streams architecture can be found here
Install
go get github.com/vimeda/pletter
Use
Pletter is simple to use, we provide you a few functions to deal with the message.
When producing messages:
// Create your proto message
ac := pb.Example{
ID: "1231231312",
}
// call the PackAndMarshal function to wrap your message and already proto.Marshal it
raw, err := any.PackAndMarshal(&ac)
if err != nil {
fmt.Errorf("an error ocurred while packing and marshalling the message: %s", err)
}
// send the slice of byte to your message broker
When consuming messages:
// declare your expected type
var expectedExample pb.Example
// call the Unpack function that will unwrap your message from the envelop
err = any.Unpack(raw, &expectedExample)
if err != nil {
fmt.Errorf("an error ocurred while unpacking the message: %s", err)
}
You can also filter out messages when consuming them:
// call the Unpack function that will unwrap your message from the envelop
name, err := any.GetMessageName(raw)
if err != nil {
fmt.Errorf("an error ocurred while getting the message name: %s", err)
}
switch name {
case "pb.Example":
// declare your expected type
var expectedExample pb.Example
// call the Unpack function that will unwrap your message from the envelop
err = any.Unpack(raw, &expectedExample)
if err != nil {
fmt.Errorf("an error ocurred while unpacking the message: %s", err)
}
// do somthing
default;
// ignore the other messages
}
Run tests
go test ./...
Author
๐ค Italo Vietro
- Github: @italolelis
๐ค Felipe Umpierre
- Github: @felipeumpierre
๐ค Contributing
Contributions, issues and feature requests are welcome!Feel free to check issues page.