-
Notifications
You must be signed in to change notification settings - Fork 101
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
Protobufectomy #1077
base: master
Are you sure you want to change the base?
Protobufectomy #1077
Conversation
efcd187
to
5d4080a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So far I've only reviewed changes to client-api-messages
, the Rust SDK and its codegen. Those look excellent. I've left a few low-priority questions and doc-related suggestions.
/// It also will not check for duplicate IDs. They are just a way to match responses to messages. | ||
#[derive(Deserialize, Serialize, serde::Deserialize)] | ||
pub struct OneOffQuery { | ||
pub message_id: Vec<u8>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a Vec<u8>
rather than a u32
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's like that on older proto schema, we have a ticket to fix this - #927 waiting for breaking release. May be, this is a correct time to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that'd be great, I'd been wondering about that as well.
/// Query should be a "SELECT * FROM Table WHERE ...". Other types of queries will be rejected. | ||
/// Multiple such semicolon-delimited queries are allowed. | ||
/// | ||
/// One-off queries are identified by a client-generated messageID. | ||
/// To avoid data leaks, the server will NOT cache responses to messages based on UUID! | ||
/// It also will not check for duplicate IDs. They are just a way to match responses to messages. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc comments should be moved to fields.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ya - I tried to do that for the most part; most/all of the comments are copied from the protobuf, which tended to put field docs on the outer type.
pub struct Subscribe { | ||
/// A sequence of SQL queries. | ||
pub query_strings: Vec<String>, | ||
pub request_id: u32, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc comment please.
// /// A reducer specified by its numerical ID. | ||
// Id(u32), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this in here?
pub struct CallReducer<Args> { | ||
/// The name or id of the reducer to call. | ||
pub reducer: ReducerId, | ||
/// The arguments to the reducer, encoded as ????. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
????
use crate::timestamp::Timestamp; | ||
|
||
#[derive(Deserialize, Serialize, serde::Deserialize)] | ||
pub enum ClientMessage<Args = Row> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub enum ClientMessage<Args = Row> { | |
/// A message sent by the client to the server. | |
pub enum ClientMessage<Args = Row> { |
} | ||
|
||
#[derive(Serialize, Deserialize, derive_more::From)] | ||
pub enum ServerMessage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub enum ServerMessage { | |
/// A message sent by the server to the client. | |
pub enum ServerMessage { |
} | ||
} | ||
} | ||
pub use spacetimedb_lib::Identity; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This closes an outstanding ticket I had. You're my hero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lol - it was breaking something with a type mismatch and I didn't wanna do a from_bytes(to_bytes())
thing to convert it so this seemed simple enough lol.
Outstanding TODOs:
(Plus make the tests and lints pass, obviously.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all seems straightforward enough, I don't have any particular commentary. Thanks for getting it in!
I wonder if I can auto-generate the C# side of this interface...
@@ -45,6 +45,9 @@ mod sym { | |||
/// Matches `sats`. | |||
pub const SATS: Symbol = Symbol("sats"); | |||
|
|||
/// Matches `transparent`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this used on stuff in this PR? Just curious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Additional question: how do we negotiate protocol version now? I believe protobuf transparently supports changing schemas for the most part by making everything optional, but I don't think bsatn has anything like that. We should at minimum send a version number I think, either once per session or once per message...
@@ -0,0 +1,266 @@ | |||
use bytes::Bytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would like a module doc comment, also a crate doc comment.
use crate::timestamp::Timestamp; | ||
|
||
#[derive(Deserialize, Serialize, serde::Deserialize)] | ||
pub enum ClientMessage<Args = Row> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to add additional messages here for protocol version negotiation?
crates/client-api-messages/src/ws.rs
Outdated
pub inserts: Vec<Row>, | ||
} | ||
|
||
#[derive(Debug, Clone)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#[derive(Debug, Clone)] | |
#[derive(Debug, Clone, From)] |
crates/client-api-messages/src/ws.rs
Outdated
impl From<Bytes> for Row { | ||
fn from(b: Bytes) -> Self { | ||
Row(b) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
impl From<Bytes> for Row { | |
fn from(b: Bytes) -> Self { | |
Row(b) | |
} | |
} |
pub mod name; | ||
pub mod recovery; | ||
pub mod timestamp; | ||
pub mod ws; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub mod ws; | |
pub mod web_socket; |
@@ -21,17 +21,28 @@ pub(crate) struct SatsType<'a> { | |||
pub(crate) enum SatsTypeData<'a> { | |||
Product(Vec<SatsField<'a>>), | |||
Sum(Vec<SatsVariant<'a>>), | |||
Transparent(SatsField<'a>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add some docs here?
crates/core/src/host/module_host.rs
Outdated
@@ -642,6 +618,11 @@ impl ModuleHost { | |||
&self.info.subscriptions | |||
} | |||
|
|||
/// internal method to access the DatabaseInstanceContext for the module. don't make this public. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be reflected in the method name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like to request that the method becomes public API.
The lifetimes of dbic and module should become coupled anyway.
@@ -2,3 +2,6 @@ pub mod control_db; | |||
pub mod control_worker_api; | |||
pub mod instance_db_trace_log; | |||
pub mod worker_db; | |||
pub mod ws { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub mod ws { | |
pub mod web_socket { |
e55d78c
to
4d5cdbc
Compare
5e9d2e2
to
f77bfac
Compare
f77bfac
to
f111123
Compare
f111123
to
14b19e0
Compare
Description of Changes
Replace protobuf with bsatn.
API and ABI breaking changes
API breaking for binary clients.
Expected complexity level and risk
3 (lotsa churn)
Testing
This is dependent on the C# sdk getting updated. I feel confident that CI + a botstest with the updated sdk would get everything.