zaphiro-technologies / protobuf

A repository including protocol buffer used in Zaphiro's platform
Apache License 2.0
0 stars 0 forks source link

SynchroGuard's Protocol Buffer Messages

In SynchroGuard, real-time data exchange relies on protocol buffer messages exchanged over RabbitMQ. Thus, consuming and/or publishing protocol buffer messages on RabbitMQ is the preferred way to integrate third parties with SynchroGuard for real-time data exchange.

This repository includes the Protocol Buffer used in Zaphiro's platform and the generated code for GO and Python.

Available Protocol Buffer Messages

At the time being this repository includes the following Protocol Buffer packages:

All protocol buffers are documented in docs.

Installation

Currently code is generated for:

Python

Installation was tested with poetry:

poetry add git+https://github.com/zaphiro-technologies/protobuf.git#v0.0.7

Go

go get -v github.com/zaphiro-technologies/protobuf/go@v0.0.7

Examples

For your convenience, in the examples folder we provide Go code to:

Requirements

Produce and consume measurements

Go

  1. Set-up the infrastructure using make docker-start.
  2. Launch the example make example-measurements-go
  3. Press any key to stop.
Getting started with Streaming client for RabbitMQ
Connecting to RabbitMQ streaming ...
Sent 10 messages
Press any key to stop

consumer name: my_consumer, measurement_id: Dev0000-0005, measurement_time 1720698360980, measurement_type 20, measurement_value 4592455024224327647
consumer name: my_consumer, measurement_id: Dev0000-0006, measurement_time 1720698360980, measurement_type 20, measurement_value 4604241342922663796
consumer name: my_consumer, measurement_id: Dev0000-0009, measurement_time 1720698360980, measurement_type 44, measurement_value 4603643564277470555
consumer name: my_consumer, measurement_id: Dev0000-0001, measurement_time 1720698360980, measurement_type 28, measurement_value 4598295346455196891
consumer name: my_consumer, measurement_id: Dev0000-0004, measurement_time 1720698360980, measurement_type 20, measurement_value 4605375802349382247
consumer name: my_consumer, measurement_id: Dev0000-0007, measurement_time 1720698360980, measurement_type 20, measurement_value 4605095969928423361
consumer name: my_consumer, measurement_id: Dev0000-0002, measurement_time 1720698360980, measurement_type 21, measurement_value 4600833284970982103
consumer name: my_consumer, measurement_id: Dev0000-0008, measurement_time 1720698360980, measurement_type 20, measurement_value 4597854724057569946
consumer name: my_consumer, measurement_id: Dev0000-0000, measurement_time 1720698360980, measurement_type 13, measurement_value 4603013690508174157
consumer name: my_consumer, measurement_id: Dev0000-0003, measurement_time 1720698360980, measurement_type 21, measurement_value 4598093240485266093
consumer name: my_consumer, measurement_id: Dev0000-0008, measurement_time 1720698360980, measurement_type 20, measurement_value 4600766170106400936
consumer name: my_consumer, measurement_id: Dev0000-0007, measurement_time 1720698360980, measurement_type 20, measurement_value 4606916483465028581

Produce and consume faults

Go

  1. Set-up the infrastructure using make docker-start.
  2. Launch the example make example-faults-go
  3. Press any key to stop.
Getting started with AMPQ client for RabbitMQ
Connecting to RabbitMQ ...
Received a fault event message: 1948cd36-f835-4dc5-83c2-ba5a7612362a, event type: FAULT_EVENT_TYPE_STARTED
Press any key to stop

Received a fault event message: 1948cd36-f835-4dc5-83c2-ba5a7612362a, event type: FAULT_EVENT_TYPE_ENDED
Received a line fault event message: 1948cd36-f835-4dc5-83c2-ba5a7612362a, event type: FAULT_EVENT_TYPE_LOCATED, faulty line: EQ-1, probability: 0.330000, length from t1: 0.526424
Received a line fault event message: 1948cd36-f835-4dc5-83c2-ba5a7612362a, event type: FAULT_EVENT_TYPE_LOCATED, faulty line: EQ-2, probability: 0.330000, length from t1: 0.484818
Received a line fault event message: 1948cd36-f835-4dc5-83c2-ba5a7612362a, event type: FAULT_EVENT_TYPE_LOCATED, faulty line: EQ-3, probability: 0.330000, length from t1: 0.315550

Contributing to Protocol Buffers

Should you need to modify the protocol buffer message or add new ones, you will need to set-up the dependencies listed in Requirements.

Protocol buffers are versioned (current version is v1), and should be developed following best practices, as implemented by Buf and defined in Protobuf programming guides. In particular, it is important - even more within the same version - to preserve compatibility, to avoid services breaking up.

You find contributing guidelines here.

Requirements

  1. Golang
  2. Protocol Buffer Compiler
  3. Go plugins for the protocol compiler
  4. Buf
  5. proto-gen-md-diagrams

Generate Code from Protocol Buffers

make generate

Generate Documentation from Protocol Buffers

make docs

Lint Protocol Buffers

make proto-lint

References

  1. 10 Protobuf Versioning Best Practices
  2. Protos Best Practices