Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Protobuf in the Example #64

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/tutorial/buf.gen.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

version: v1
plugins:
- plugin: buf.build/community/neoeinstein-prost:v0.2.2
out: src/pb
opt:
- file_descriptor_set=false

- plugin: buf.build/community/neoeinstein-prost-crate:v0.3.1
out: src/pb
opt:
- no_features
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
syntax = "proto3";

package eth.block_meta.v1;
package eth_block_meta.v1;

import "google/protobuf/timestamp.proto";

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ mod block_timestamp;
mod pb;

use self::block_timestamp::BlockTimestamp;
use pb::block_meta::BlockMeta;
use pb::eth_block_meta::v1::BlockMeta;
use substreams::store::{
self, DeltaProto, StoreNew, StoreSetIfNotExists, StoreSetIfNotExistsProto,
};
Expand Down
49 changes: 0 additions & 49 deletions docs/tutorial/src/pb/eth.block_meta.v1.rs

This file was deleted.

14 changes: 14 additions & 0 deletions docs/tutorial/src/pb/eth_block_meta.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// @generated
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct BlockMeta {
#[prost(uint64, tag="1")]
pub number: u64,
#[prost(bytes="vec", tag="2")]
pub hash: ::prost::alloc::vec::Vec<u8>,
#[prost(bytes="vec", tag="3")]
pub parent_hash: ::prost::alloc::vec::Vec<u8>,
#[prost(message, optional, tag="4")]
pub timestamp: ::core::option::Option<::prost_types::Timestamp>,
}
// @@protoc_insertion_point(module)
38 changes: 35 additions & 3 deletions docs/tutorial/src/pb/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
#[path = "eth.block_meta.v1.rs"]
#[allow(dead_code)]
pub mod block_meta;
// @generated
pub mod eth_block_meta {
// @@protoc_insertion_point(attribute:eth_block_meta.v1)
pub mod v1 {
include!("eth_block_meta.v1.rs");
// @@protoc_insertion_point(eth_block_meta.v1)
}
}
pub mod sf {
pub mod substreams {
pub mod sink {
pub mod database {
// @@protoc_insertion_point(attribute:sf.substreams.sink.database.v1)
pub mod v1 {
include!("sf.substreams.sink.database.v1.rs");
// @@protoc_insertion_point(sf.substreams.sink.database.v1)
}
}
pub mod kv {
// @@protoc_insertion_point(attribute:sf.substreams.sink.kv.v1)
pub mod v1 {
include!("sf.substreams.sink.kv.v1.rs");
// @@protoc_insertion_point(sf.substreams.sink.kv.v1)
}
}
pub mod types {
// @@protoc_insertion_point(attribute:sf.substreams.sink.types.v1)
pub mod v1 {
include!("sf.substreams.sink.types.v1.rs");
// @@protoc_insertion_point(sf.substreams.sink.types.v1)
}
}
}
}
}
82 changes: 82 additions & 0 deletions docs/tutorial/src/pb/sf.substreams.sink.database.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// @generated
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct DatabaseChanges {
#[prost(message, repeated, tag="1")]
pub table_changes: ::prost::alloc::vec::Vec<TableChange>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct TableChange {
#[prost(string, tag="1")]
pub table: ::prost::alloc::string::String,
#[prost(uint64, tag="3")]
pub ordinal: u64,
#[prost(enumeration="table_change::Operation", tag="4")]
pub operation: i32,
#[prost(message, repeated, tag="5")]
pub fields: ::prost::alloc::vec::Vec<Field>,
#[prost(oneof="table_change::PrimaryKey", tags="2, 6")]
pub primary_key: ::core::option::Option<table_change::PrimaryKey>,
}
/// Nested message and enum types in `TableChange`.
pub mod table_change {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Operation {
/// Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified
Unspecified = 0,
Create = 1,
Update = 2,
Delete = 3,
}
impl Operation {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Operation::Unspecified => "OPERATION_UNSPECIFIED",
Operation::Create => "OPERATION_CREATE",
Operation::Update => "OPERATION_UPDATE",
Operation::Delete => "OPERATION_DELETE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"OPERATION_UNSPECIFIED" => Some(Self::Unspecified),
"OPERATION_CREATE" => Some(Self::Create),
"OPERATION_UPDATE" => Some(Self::Update),
"OPERATION_DELETE" => Some(Self::Delete),
_ => None,
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Oneof)]
pub enum PrimaryKey {
#[prost(string, tag="2")]
Pk(::prost::alloc::string::String),
#[prost(message, tag="6")]
CompositePk(super::CompositePrimaryKey),
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct CompositePrimaryKey {
#[prost(map="string, string", tag="1")]
pub keys: ::std::collections::HashMap<::prost::alloc::string::String, ::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Field {
#[prost(string, tag="1")]
pub name: ::prost::alloc::string::String,
#[prost(string, tag="2")]
pub new_value: ::prost::alloc::string::String,
#[prost(string, tag="3")]
pub old_value: ::prost::alloc::string::String,
}
// @@protoc_insertion_point(module)
162 changes: 162 additions & 0 deletions docs/tutorial/src/pb/sf.substreams.sink.kv.v1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// @generated
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KvOperations {
#[prost(message, repeated, tag="1")]
pub operations: ::prost::alloc::vec::Vec<KvOperation>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct KvOperation {
#[prost(string, tag="1")]
pub key: ::prost::alloc::string::String,
#[prost(bytes="vec", tag="2")]
pub value: ::prost::alloc::vec::Vec<u8>,
#[prost(uint64, tag="3")]
pub ordinal: u64,
#[prost(enumeration="kv_operation::Type", tag="4")]
pub r#type: i32,
}
/// Nested message and enum types in `KVOperation`.
pub mod kv_operation {
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]
#[repr(i32)]
pub enum Type {
/// Protobuf default should not be used, this is used so that the consume can ensure that the value was actually specified
Unset = 0,
Set = 1,
Delete = 2,
}
impl Type {
/// String value of the enum field names used in the ProtoBuf definition.
///
/// The values are not transformed in any way and thus are considered stable
/// (if the ProtoBuf definition does not change) and safe for programmatic use.
pub fn as_str_name(&self) -> &'static str {
match self {
Type::Unset => "UNSET",
Type::Set => "SET",
Type::Delete => "DELETE",
}
}
/// Creates an enum from field names used in the ProtoBuf definition.
pub fn from_str_name(value: &str) -> ::core::option::Option<Self> {
match value {
"UNSET" => Some(Self::Unset),
"SET" => Some(Self::Set),
"DELETE" => Some(Self::Delete),
_ => None,
}
}
}
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetRequest {
/// Key to fetch
#[prost(string, tag="1")]
pub key: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetManyRequest {
/// Keys to fetch
#[prost(string, repeated, tag="1")]
pub keys: ::prost::alloc::vec::Vec<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetByPrefixRequest {
/// server may impose a hard limit, trying to go above it would return grpc_error: INVALID_ARGUMENT
#[prost(uint64, tag="1")]
pub limit: u64,
/// requested prefix
#[prost(string, tag="2")]
pub prefix: ::prost::alloc::string::String,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScanRequest {
/// server may impose a hard limit, trying to go above it would return grpc_error: INVALID_ARGUMENT
#[prost(uint64, tag="1")]
pub limit: u64,
/// scanning will start at this point, lexicographically
#[prost(string, tag="2")]
pub begin: ::prost::alloc::string::String,
/// If set, scanning will stop when it reaches this point or above, excluding this exact key
#[prost(string, optional, tag="3")]
pub exclusive_end: ::core::option::Option<::prost::alloc::string::String>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetResponse {
/// Value that was found for the requested key
#[prost(bytes="vec", tag="1")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetManyResponse {
/// Values that were found for the requested keys
#[prost(bytes="vec", repeated, tag="1")]
pub values: ::prost::alloc::vec::Vec<::prost::alloc::vec::Vec<u8>>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GetByPrefixResponse {
/// KV are the key/value pairs that were found with the given prefix
#[prost(message, repeated, tag="1")]
pub key_values: ::prost::alloc::vec::Vec<Kv>,
/// limit_reached is true if there is at least ONE MORE result than the requested limit
#[prost(bool, tag="2")]
pub limit_reached: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct ScanResponse {
/// KV are the key/value pairs that were found during scan
#[prost(message, repeated, tag="1")]
pub key_values: ::prost::alloc::vec::Vec<Kv>,
/// limit_reached is true if there is at least ONE MORE result than the requested limit
#[prost(bool, tag="2")]
pub limit_reached: bool,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Kv {
#[prost(string, tag="1")]
pub key: ::prost::alloc::string::String,
#[prost(bytes="vec", tag="2")]
pub value: ::prost::alloc::vec::Vec<u8>,
}
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Config {
#[prost(int64, tag="1")]
pub start_block: i64,
#[prost(string, tag="2")]
pub input_module: ::prost::alloc::string::String,
}
/// This defines a KV Sink to be queried with a generic key access interface (Get, GetMany, Scan, Prefix calls).
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenericService {
#[prost(message, optional, tag="1")]
pub sink_config: ::core::option::Option<Config>,
}
/// This defines configuration to run a WASM query service on top of the KV store being sync'd.
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct WasmQueryService {
#[prost(message, optional, tag="1")]
pub sink_config: ::core::option::Option<Config>,
/// wasm exports: "kv_get_batch", "kv_get", "kv_scan", "kv_prefix"
#[prost(bytes="vec", tag="5")]
pub wasm_query_module: ::prost::alloc::vec::Vec<u8>,
/// Fully qualified Protobuf Service definition name
///
/// sf.mycustom.v1.MyService
#[prost(string, tag="2")]
pub grpc_service: ::prost::alloc::string::String,
}
// @@protoc_insertion_point(module)
Loading
Loading