Skip to content

Commit 83cea9c

Browse files
author
Guy Baron
authored
added documentation on serialization support (#177)
* fixed emperror url format * added serialization documentation
1 parent edc7c1a commit 83cea9c

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ A lightweight transactional message bus on top of RabbitMQ supporting:
2323
7) [Structured logging](https://github.com/wework/grabbit/blob/master/docs/LOGGING.md)
2424
8) Reporting [Metrics](https://github.com/wework/grabbit/blob/master/docs/METRICS.md) via Prometheus
2525
9) Distributed [Tracing](https://github.com/wework/grabbit/blob/master/docs/TRACING.md) via OpenTracing
26+
10) [Extensible serialization](https://github.com/wework/grabbit/blob/master/docs/SERIALIZATION.md) with
27+
default support for gob, protobuf and avro
2628

2729
## Stable release
2830
the v1.x branch contains the latest stable releases of grabbit and one should track that branch to get point and minor release updates.

docs/LOGGING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func SomeHandler(invocation gbus.Invocation, message *gbus.BusMessage) error{
5050
}
5151
```
5252
grabbit makes it easier handling these cases and reduce the repetitive task of logging
53-
these custom contextual attributes in cases of errors by integrating the [emperror errors package] (https://github.com/emperror/errors).
53+
these custom contextual attributes in cases of errors by integrating the [emperror errors package](https://github.com/emperror/errors).
5454
emperror drop-in replacement for the default errors package allows developers to add the needed contextual data on the error instance and have graabit log the error with all contextual attribute.
5555

5656
```go

docs/SERIALIZATION.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Serialization
2+
3+
grabbit supports out of the box three serializers to format messages over the wire
4+
5+
- gob (defualt)
6+
- protobuf
7+
- avro (experimental)
8+
9+
To configure a bus to work with a different serializer than the default one you must call the WithSerializer function call on the builder interface passing it an instance of a gbus.Serializer.
10+
11+
The following example configures the bus to work with the protobuf serializer
12+
13+
```go
14+
package main
15+
16+
import (
17+
"github.com/sirupsen/logrus"
18+
"github.com/wework/grabbit/gbus"
19+
"github.com/wework/grabbit/gbus/builder"
20+
"github.com/wework/grabbit/gbus/serialization"
21+
)
22+
23+
logger := logrus.New()
24+
bus := builder.
25+
New().
26+
Bus("rabbitmq connection string").
27+
WithLogger(logger).
28+
WithSerializer(serialization.NewProtoSerializer(logger)).
29+
WorkerNum(3, 1).
30+
WithConfirms().
31+
Txnl("mysql", "database connection string").
32+
Build("your service name")
33+
34+
```
35+

0 commit comments

Comments
 (0)