flow: move schemas into a dedicated directory

This helps exposing them with docker-compose.
This commit is contained in:
Vincent Bernat
2022-03-20 21:58:54 +01:00
parent 41131fca96
commit ccd839ef97
5 changed files with 6 additions and 6 deletions

View File

@@ -47,8 +47,8 @@ $(BIN)/protoc-gen-go: PACKAGE=google.golang.org/protobuf/cmd/protoc-gen-go
# Generated files # Generated files
%.pb.go: %.proto | $(PROTOC_GEN_GO) ; $(info $(M) compiling protocol buffers definition) flow/%.pb.go: flow/data/schemas/%.proto | $(PROTOC_GEN_GO) ; $(info $(M) compiling protocol buffers definition)
$Q $(PROTOC) -I=. --plugin=$(PROTOC_GEN_GO) --go_out=. --go_opt=paths=source_relative $< $Q $(PROTOC) -I=. --plugin=$(PROTOC_GEN_GO) --go_out=. --go_opt=module=$(MODULE) $<
web/data: mkdocs.yml $(wildcard docs/*.md docs/assets/*) ; $(info $(M) build documentation) @ ## Build documentation web/data: mkdocs.yml $(wildcard docs/*.md docs/assets/*) ; $(info $(M) build documentation) @ ## Build documentation
$Q rm -rf web/data $Q rm -rf web/data

View File

@@ -30,4 +30,4 @@ services:
- 8123:8123/tcp - 8123:8123/tcp
- 9000:9000/tcp - 9000:9000/tcp
volumes: volumes:
- ./flow/flow-v0.proto:/var/lib/clickhouse/format_schemas/flow-v0.proto:ro - ./flow/data/schemas:/var/lib/clickhouse/format_schemas:ro

View File

@@ -16,13 +16,13 @@ const CurrentSchemaVersion = 0
var ( var (
// VersionedSchemas is a mapping from schema version to protobuf definitions // VersionedSchemas is a mapping from schema version to protobuf definitions
VersionedSchemas map[int]string VersionedSchemas map[int]string
//go:embed flow*.proto //go:embed data/schemas/flow*.proto
schemas embed.FS schemas embed.FS
) )
func init() { func init() {
VersionedSchemas = make(map[int]string) VersionedSchemas = make(map[int]string)
entries, err := schemas.ReadDir(".") entries, err := schemas.ReadDir("data/schemas")
if err != nil { if err != nil {
panic(err) panic(err)
} }
@@ -34,7 +34,7 @@ func init() {
if err != nil { if err != nil {
panic(err) panic(err)
} }
f, err := schemas.Open(entry.Name()) f, err := schemas.Open(fmt.Sprintf("data/schemas/%s", entry.Name()))
if err != nil { if err != nil {
panic(err) panic(err)
} }