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

spec: Allow specifying service schema names & encodings #563

Conversation

achim-k
Copy link
Collaborator

@achim-k achim-k commented Oct 25, 2023

Public-Facing Changes

spec: Allow specifying service schema names & encodings

Description

Allows for customization of service schema names and schema encodings.

Partially fixes https://github.com/foxglove/studio/issues/6970
Partially resolves FG-5280

@jhurliman
Copy link
Contributor

Nice, LGTM

docs/spec.md Outdated
@@ -206,8 +206,14 @@ Informs the client about available services. Only supported if the server declar
- `id`: number. The server may reuse ids when services disappear and reappear, but only if the services keeps the exact same name, type, and schema. Clients will use this unique id to cache schema info and deserialization routines.
- `name`: string
- `type`: string
- `requestSchema`: string
- `responseSchema`: string
- `requestSchema`: string (schema data only) or object with the fields below. If given as string, schema name and encoding will be derived from `type` (by appending `_Request`) and the previously advertised [supportedEncodings](#server-info).
Copy link
Member

Choose a reason for hiding this comment

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

I'm confused about what it means to derive the schema encoding from supportedEncodings, because I thought those were message encodings, not schema encodings?

Copy link
Member

Choose a reason for hiding this comment

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

I guess we also need a response message encoding in addition to response schema encoding?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm confused about what it means to derive the schema encoding from supportedEncodings, because I thought those were message encodings, not schema encodings?

As serviceCallEncoding (message encoding) we pick one of the supported encodings from supportedEncodings and then derive the schema encoding from that:

https://github.com/foxglove/studio/blob/2c854ffb9c5a3676fb22818206d581bb1c08cf0f/packages/studio-base/src/players/FoxgloveWebSocketPlayer/index.ts#L606-L615

It's quite some magic. Maybe we just add messageEncoding to the objects that I have added in this PR?

Copy link
Member

Choose a reason for hiding this comment

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

Naming is hard... what do you think of:

request: {
  encoding: string
  schemaName: string
  schemaEncoding: string
  schema: string
}

or

requestEncoding: string
requestSchema: {
  name: string
  encoding: string
  data: string
}

or something like that?

cc @defunctzombie for thoughts

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am in favor of the 1st option

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Applied the changes. OK for you like that @jtbandes @jhurliman @defunctzombie ?

@achim-k achim-k requested a review from jtbandes October 30, 2023 16:48
Copy link
Member

@jtbandes jtbandes left a comment

Choose a reason for hiding this comment

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

LGTM, would wait for @defunctzombie to sign off as well

Copy link
Contributor

@defunctzombie defunctzombie left a comment

Choose a reason for hiding this comment

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

Maybe it is documented elsewhere or obvious to others but I have no idea what any of the fields in the services array are suppose to be. id has some more detailed documentation but all the other fields only have a plain type (string, object). Reading request I've no idea what I am suppose to think about this field, how do I populate it, what is it for? The same is true for encoding. How is that different than schemaEncoding? What would I typically put in these? How does it relate to the schema field?

All of those questions I cannot answer reading the spec. I see an example which helps but whether I would be able to turn that into an equivalent for other systems I am not sure.

Related: what is "encoding"? Why is it important to note ros1 in the encoding? We already have a schemaEncoding of ros1msg. These are things that more descriptions on the fields might have made obvious but since there are not any I don't know what purpose this field serves that others have not already served.

@defunctzombie
Copy link
Contributor

Awesome! Thank you for adding the descriptions. This is all clear to me now.

@defunctzombie defunctzombie merged commit 5635649 into main Nov 4, 2023
10 checks passed
@defunctzombie defunctzombie deleted the achim/fg-5280-service-calls-make-ros-assumptions-with-_request-and branch November 4, 2023 00:20
achim-k added a commit that referenced this pull request Nov 9, 2023
### Public-Facing Changes

@foxglove/ws-protocol: Update to spec changes

### Description
Adapts @foxglove/ws-protocol to the latest spec changes made in #563

Related to FG-5280
pezy pushed a commit to pezy/studio that referenced this pull request Sep 14, 2024
…7102)

**User-Facing Changes**
Remove ROS assumptions when using services with foxglove websocket

**Description**
Updates the websocket player to comply with the latest `ws-protocol`
spec changes made in foxglove/ws-protocol#563.
This allows to remove some ROS specific assumptions which makes it
easier to advertise services from non-ROS systems.

Fixes #6970
Resolves FG-5280
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants