2020-06-05 20:22:27 +00:00
|
|
|
[package]
|
2020-11-05 18:44:36 +00:00
|
|
|
name = "generated_types"
|
2020-06-05 20:22:27 +00:00
|
|
|
version = "0.1.0"
|
|
|
|
authors = ["Paul Dix <paul@pauldix.net>"]
|
2021-10-25 08:45:44 +00:00
|
|
|
edition = "2021"
|
2020-06-05 20:22:27 +00:00
|
|
|
|
2021-02-04 23:56:02 +00:00
|
|
|
[dependencies] # In alphabetical order
|
2022-05-23 15:37:31 +00:00
|
|
|
base64 = "0.13"
|
2022-07-20 10:00:08 +00:00
|
|
|
bytes = "1.2"
|
2022-05-05 19:29:24 +00:00
|
|
|
data_types = { path = "../data_types", optional = true }
|
2022-02-25 17:49:42 +00:00
|
|
|
datafusion = { path = "../datafusion", optional = true }
|
2021-09-16 07:33:27 +00:00
|
|
|
observability_deps = { path = "../observability_deps" }
|
2022-09-21 09:34:47 +00:00
|
|
|
pbjson = "0.5"
|
2022-09-21 09:44:26 +00:00
|
|
|
pbjson-types = "0.5"
|
2022-02-25 17:49:42 +00:00
|
|
|
predicate = { path = "../predicate", optional = true }
|
2022-08-09 17:30:44 +00:00
|
|
|
prost = "0.11"
|
2022-04-29 14:06:50 +00:00
|
|
|
query_functions = { path = "../query_functions" }
|
feat: Derive serde for protos
Rationale
---------
Our CLI needs to be able to accept configuration as JSON and render configuration as JSON.
Protobufs technically have an official JSON encoding rule called 'jsonpb` but prost doesn't
offer native supprot for it.
`prost` allows us to specify arbitrary derive metadata to be added to generated
code. We emit the `serde` derive directives in the two packages that generate prost code
(`generated_types` and `google_types`).
We use the `serde(rename_all = "camelCase")` to approximate `jsonpb`.
We instruct `prost` to use `bytes::Bytes` for some types, hence we must turn on the `serde` feature
on the `bytes` dependency.
We also use json to serialize the output of the `database get` command, to showcase the feature
and get rid of a TODO. In a subsequent PR I'll teach `database create` (and the yet to be done `database update`) to accept an option JSON configuration body so we can configure partitioning, lifecycle, sharding etc rules etc.
Caveats
-------
This is not technically `jsonpb`. Main issues:
1. default values not omitted
2. no special rendering of special types like `google.protobuf.Any`
Future work
-----------
Figure out if we can get fully compliant `jsonpb`, or at least a decent approximation.
Effect
------
```console
$ cargo run -- database get foobar_weather
{
"name": "foobar_weather",
"partitionTemplate": {
"parts": [
{
"part": {
"time": "%Y-%m-%d %H:00:00"
}
}
]
},
"lifecycleRules": {
"mutableLingerSeconds": 0,
"mutableMinimumAgeSeconds": 0,
"mutableSizeThreshold": 0,
"bufferSizeSoft": 0,
"bufferSizeHard": 0,
"sortOrder": {
"order": 2,
"sort": {
"createdAtTime": {}
}
},
"dropNonPersisted": false,
"immutable": false
},
"walBufferConfig": null,
"shardConfig": {
"specificTargets": null,
"hashRing": null,
"ignoreErrors": false
}
}
```
2021-03-30 02:29:47 +00:00
|
|
|
serde = { version = "1.0", features = ["derive"] }
|
2022-05-23 15:37:31 +00:00
|
|
|
snafu = "0.7"
|
2022-08-09 17:30:44 +00:00
|
|
|
tonic = "0.8"
|
2021-11-19 14:21:57 +00:00
|
|
|
workspace-hack = { path = "../workspace-hack"}
|
2021-02-12 16:14:53 +00:00
|
|
|
|
2021-02-04 23:56:02 +00:00
|
|
|
[build-dependencies] # In alphabetical order
|
2022-08-09 17:30:44 +00:00
|
|
|
tonic-build = "0.8"
|
|
|
|
prost-build = "0.11"
|
|
|
|
pbjson-build = "0.4"
|
2021-10-05 15:07:45 +00:00
|
|
|
|
2022-05-23 15:37:31 +00:00
|
|
|
[dev-dependencies]
|
|
|
|
data_types = { path = "../data_types" }
|
|
|
|
datafusion = { path = "../datafusion" }
|
|
|
|
predicate = { path = "../predicate" }
|
|
|
|
|
2021-10-05 15:07:45 +00:00
|
|
|
[features]
|
2022-01-28 16:38:59 +00:00
|
|
|
default = ["data_types_conversions"]
|
2022-05-05 19:29:24 +00:00
|
|
|
data_types_conversions = ["data_types", "datafusion", "predicate"]
|