Skip to content

Comments

Include services in reflection data (fixes #4639)#4713

Merged
aardappel merged 3 commits intogoogle:masterfrom
xbr:expand_reflection
Apr 27, 2018
Merged

Include services in reflection data (fixes #4639)#4713
aardappel merged 3 commits intogoogle:masterfrom
xbr:expand_reflection

Conversation

@oberstet
Copy link
Contributor

@oberstet oberstet commented Apr 23, 2018

supersedes #4711 : squashed

the main change: expanding the reflection schema https://github.com/google/flatbuffers/pull/4713/files#diff-db35d829e5e236af29f9a061c8352dcb

@oberstet oberstet changed the title include service in reflection data (fixes #4639) Include services in reflection data (fixes #4639) Apr 23, 2018
Copy link
Collaborator

@aardappel aardappel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly looks good! A few issues..

struct RPCCall : public Definition {
Offset<reflection::RPCCall> Serialize(FlatBufferBuilder *builder, const Parser &parser) const;

std::string name;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definition also contains a name and doc_comment already, so these can be removed below.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=> attributes removed (note: the use of doc_comment from the base class instead of the dedicated and now removed rpc_comment triggered small changes elsewhere)

@@ -44,6 +44,7 @@ table EnumVal {
value:long (key);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is generate_code.sh changed (can't comment on that actual file)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added executable flag (as with most other scripts in the repo)


table RPCCall {
name:string (required, key);
request:Object (required); // must be a table (not a struct)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having these two being an Object requires RPCCalls to be serialized after objects.. which is fine I guess. An alternative would be an index into objects much like elsewhere.

Copy link
Contributor Author

@oberstet oberstet Apr 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you mean here. I tried to follow closely the rest of the model - and the model works (I am using the new stuff, a bfbs file generated, reading from Python). Could you expand? What is the concern, or how would I write the reflection schema differently?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no problem, merely noting the consequences of this choice.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of it being an index into objects(). Otherwise this would duplicate some data serialized into objects, correct?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@englercj No, this makes no difference in terms of size, since objects are serialized once regardless.

enums:[Enum] (required); // Sorted.
objects:[Object] (required); // Sorted.
enums:[Enum] (required); // Sorted.
services:[Service]; // Sorted.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inserting fields in the middle like this is an incompatible change and would make this schema incompatible with all pre-existing binary schema files. Add at the end, or give all fields a correct id attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uups. moved services to the end

src/flatc.cpp Outdated
" --grpc Generate GRPC interfaces for the specified languages\n"
" --schema Serialize schemas instead of JSON (use with -b)\n"
" --bfbs-comments Add doc comments to the binary schema files.\n"
" --bfbs-builtin-attrs Add builtin attributes to the binary schema files.\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate to ask, but can we make this flag shorter so it lines up? :(

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to --bfbs-builtins (there is a tradeoff here;)

IsInteger(value.type.base_type) ? StringToInt(value.constant.c_str()) : 0,
IsFloat(value.type.base_type) ? strtod(value.constant.c_str(), nullptr)
: 0.0,
deprecated, required, key, SerializeAttributes(builder, parser),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was this caused by clang-format? if not, prefer not to reformat unchanged code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, this was caused by me not reverting my random reformats as I hacked on the code;) => reverted

@aardappel
Copy link
Collaborator

CI shows a segfault in the tests, can you investigate? https://travis-ci.org/google/flatbuffers/jobs/370278046

@oberstet
Copy link
Contributor Author

CI passes now: forgot to regenerate the test data

@oberstet
Copy link
Contributor Author

@aardappel ping: anything else I should do rgd the PR? thx!

@aardappel
Copy link
Collaborator

Looks good, thanks!

@aardappel aardappel merged commit 9bb88a0 into google:master Apr 27, 2018
zchee pushed a commit to zchee/flatbuffers that referenced this pull request Feb 14, 2019
* include service in reflection data (fixes google#4639)

* changes from review

* regenerated test data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants