Comments (5)
Hi @travisofthenorth - fields in Protobuf are always optional - meaning that any unspecified value will always be nil
if not passed. This allows you to do proper presence checks, which allow partial updates to happen.
For instance, take a description
- field:
message Product {
uint64 id = 1;
string name = 2;
string description = 3;
}
Lets say I wanted to update Product
, but didn't want to touch the description. Right now, description
is a native string, which means it will always come over as a string. This means if not set by the client, it will come as ""
. That's problematic for us, as how would the client differentiate between an empty description (a valid value!) and one not passed?
Google provides wrapper types, such as Google::Protobuf::StringValue
, to help with this. Lets change our message:
message Product {
uint64 id = 1;
google.protobuf.StringValue name = 2;
google.protobuf.StringValue description = 3;
}
Now, we can pass either the name or description optionally, and in our code check for nil
to see if the client meant to update that field.
So, in other words - this behavior is expected and intentional. Thanks!
from gruf.
@splittingred I'm explicitly passing in Google::Protobuf::Int32Value.new(value: 0)
from gruf.
In any case, another one of my clients doesn't seem to have this problem, so it must be something silly like a gem version in the particular client I'm looking at.
Thanks for taking a look, and apologies for the false alarm!
from gruf.
If anyone encounters this error again, this was a bug in protobuf
fixed here: protocolbuffers/protobuf#7195
from gruf.
@travisofthenorth Oh! Interesting, I misunderstood your question then (didn't realize you were asking about the wrapper value vs the main message).
Thanks for linking the protobuf fix. Appreciate it!
from gruf.
Related Issues (20)
- Gruf 2.13 with gRPC 1.42 causes an error and prevents RSpec from shutting down HOT 2
- Please release 2.13.2 HOT 4
- Next step in `Server:-Creating-Controllers.md` not linked HOT 1
- Starting Gruf and bind with specific controllers HOT 4
- After Zeitwerk upgrade, specs don't autoload controller names HOT 7
- Request context for interceptors to communicate information back to controllers HOT 2
- 2.16 appears to autoload the HealthCheck even if not enabled HOT 1
- Minor typo in wiki, recommended fix :) HOT 1
- Gruf.controllers_path unloaded even in client mode HOT 2
- Question: is hot code reloading for other paths possible? HOT 1
- healthcheck cannot be seperated of main thread limit HOT 1
- Autoloading in development is not thread-safe HOT 3
- enabling TLS default
- Allow gruf to receive request objects in `call` HOT 2
- Ruby does not generate correct proto with ruby version 3.1.0 and 3.2.0 HOT 2
- Wiki: update instrumentation docs to rename blacklist to blocklist, since that's what it is in the code. HOT 1
- Ruby 3.3.0 support HOT 1
- Gruf server stuck at starting HOT 1
- Rails 7.1: DEPRECATION WARNING: Calling `ActiveRecord::Base.clear_active_connections! is deprecated. Please call the method directly on the connection handler; for example: `ActiveRecord::Base.connection_handler.clear_active_connections! HOT 1
- Did release 2.17.0 break call concurrency? HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gruf.