1
0
mirror of https://github.com/netsampler/goflow2.git synced 2024-05-06 15:54:52 +00:00

Fix protobuf

* Rebuiild with protoc v3.17.2 and protoc-gen-go v1.26.0
* Add misisng go_package flag
* Add protobuf documentation
This commit is contained in:
lspgn
2021-06-07 22:43:09 -07:00
parent 622c41a69d
commit ab81e52b43
7 changed files with 52 additions and 25 deletions

View File

@@ -25,8 +25,8 @@ OUTPUT := $(DIST_DIR)goflow2-$(VERSION_PKG)-$(GOOS)-$(ARCH)$(EXTENSION)
.PHONY: proto
proto:
@echo generating protobuf
protoc --go_out=. pb/*.proto
protoc --go_out=. cmd/enricher/pb/*.proto
protoc --go_opt=paths=source_relative --go_out=. pb/*.proto
protoc --go_opt=paths=source_relative --go_out=. cmd/enricher/pb/*.proto
.PHONY: vet
vet:

View File

@@ -167,12 +167,7 @@ It can also be extended wtih enrichment as long as the user keep the same IDs.
If you want to develop applications, build `pb/flow.proto` into the language you want:
When adding custom fields, picking a field ID ≥ 1000 is suggested.
You can compile the protobuf using the Makefile for Go.
```
make proto
```
For compiling the protobuf for other languages, refer to the [official guide](https://developers.google.com/protocol-buffers).
Check the docs for more information about [compiling protobuf](/docs/protobuf.md).
## Flow Pipeline

View File

@@ -1,13 +1,12 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.15.0
// protoc-gen-go v1.26.0
// protoc v3.17.2
// source: cmd/enricher/pb/flowext.proto
package flowpb
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@@ -21,10 +20,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type FlowMessageExt_FlowType int32
const (
@@ -671,7 +666,11 @@ var file_cmd_enricher_pb_flowext_proto_rawDesc = []byte{
0x4c, 0x4f, 0x57, 0x5f, 0x35, 0x10, 0x01, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c,
0x4f, 0x57, 0x5f, 0x56, 0x35, 0x10, 0x02, 0x12, 0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c,
0x4f, 0x57, 0x5f, 0x56, 0x39, 0x10, 0x03, 0x12, 0x09, 0x0a, 0x05, 0x49, 0x50, 0x46, 0x49, 0x58,
0x10, 0x04, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x10, 0x04, 0x42, 0x36, 0x5a, 0x34, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
0x2f, 0x6e, 0x65, 0x74, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x2f, 0x67, 0x6f, 0x66, 0x6c,
0x6f, 0x77, 0x32, 0x2f, 0x63, 0x6d, 0x64, 0x2f, 0x65, 0x6e, 0x72, 0x69, 0x63, 0x68, 0x65, 0x72,
0x2f, 0x70, 0x62, 0x3b, 0x66, 0x6c, 0x6f, 0x77, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
}
var (

View File

@@ -1,5 +1,6 @@
syntax = "proto3";
package flowpb;
option go_package = "github.com/netsampler/goflow2/cmd/enricher/pb;flowpb";
message FlowMessageExt {

34
docs/protobuf.md Normal file
View File

@@ -0,0 +1,34 @@
# Protobuf
The `.proto` files contains a list of fields that are populated by GoFlow2.
If the fields are changed, the schema needs to be recompiled
in order to use it.
The compilation is dependent on the language.
Keep in mind the protobuf source code and libraries changes often and this page may be outdated.
For other languages, refer to the [official guide](https://developers.google.com/protocol-buffers).
## Compile for Golang
The following two tools are required:
* [protoc](https://github.com/protocolbuffers/protobuf), a protobuf compiler, written in C
* [protoc-gen-go](https://github.com/protocolbuffers/protobuf-go), a Go plugin for protoc that can compile protobuf for Golang
The release page in the respective GitHub repositories should provide binaries distributions. Unzip/Untar if necessary.
Make sure that the two binaries are in your ``$PATH``. On Mac OS you can add the files to `/usr/local/bin` for instance.
From the root of the repository, run the following command:
```bash
$ protoc --go_opt=paths=source_relative --go_out=. pb/*.proto
```
This will compile the main protobuf schema into the `pb` directory.
You can also run the command which will also compile the protobuf for the sample enricher.
```bash
$ make proto
```

View File

@@ -1,13 +1,12 @@
// Code generated by protoc-gen-go. DO NOT EDIT.
// versions:
// protoc-gen-go v1.25.0
// protoc v3.15.0
// protoc-gen-go v1.26.0
// protoc v3.17.2
// source: pb/flow.proto
package flowpb
import (
proto "github.com/golang/protobuf/proto"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
reflect "reflect"
@@ -21,10 +20,6 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// This is a compile-time assertion that a sufficiently up-to-date version
// of the legacy proto package is being used.
const _ = proto.ProtoPackageIsVersion4
type FlowMessage_FlowType int32
const (
@@ -649,8 +644,10 @@ var file_pb_flow_proto_rawDesc = []byte{
0x10, 0x00, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x35, 0x10, 0x01, 0x12,
0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x56, 0x35, 0x10, 0x02, 0x12,
0x0e, 0x0a, 0x0a, 0x4e, 0x45, 0x54, 0x46, 0x4c, 0x4f, 0x57, 0x5f, 0x56, 0x39, 0x10, 0x03, 0x12,
0x09, 0x0a, 0x05, 0x49, 0x50, 0x46, 0x49, 0x58, 0x10, 0x04, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x33,
0x09, 0x0a, 0x05, 0x49, 0x50, 0x46, 0x49, 0x58, 0x10, 0x04, 0x42, 0x29, 0x5a, 0x27, 0x67, 0x69,
0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6e, 0x65, 0x74, 0x73, 0x61, 0x6d, 0x70,
0x6c, 0x65, 0x72, 0x2f, 0x67, 0x6f, 0x66, 0x6c, 0x6f, 0x77, 0x32, 0x2f, 0x70, 0x62, 0x3b, 0x66,
0x6c, 0x6f, 0x77, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (

View File

@@ -1,5 +1,6 @@
syntax = "proto3";
package flowpb;
option go_package = "github.com/netsampler/goflow2/pb;flowpb";
message FlowMessage {