-
Notifications
You must be signed in to change notification settings - Fork 289
Data track schema definition storage #2050
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
Open
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5f5ecd0
Add data blob support to signal client
ladvoc 6ab92f8
Conversion of schema ID to data blob key
ladvoc d1aa612
Define error type
ladvoc 745a0c4
Implement define/get methods
ladvoc b896fb1
Test define/get
ladvoc 34b7c29
Changeset
ladvoc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| 'livekit-client': minor | ||
| --- | ||
|
|
||
| Added `defineSchema` and `getSchema` to `LocalParticipant` for storing and retrieving data track schema definitions |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| import { RequestResponse_Reason } from '@livekit/protocol'; | ||
| import { LivekitReasonedError } from '../errors'; | ||
|
|
||
| export enum DataTrackSchemaStorageErrorReason { | ||
| /** Request to store or retrieve a schema definition timed-out */ | ||
| Timeout = 0, | ||
| /** The participant has not defined a schema with this ID */ | ||
| NotFound = 1, | ||
| /** The server rejected the request */ | ||
| RequestFailed = 2, | ||
| /** The server response is malformed */ | ||
| MalformedResponse = 3, | ||
| /** The retrieved schema definition is not valid UTF-8 */ | ||
| InvalidDefinition = 4, | ||
| /** Request cancelled by caller */ | ||
| Cancelled = 5, | ||
| /** Cannot store or retrieve a schema definition when disconnected */ | ||
| Disconnected = 6, | ||
| } | ||
|
|
||
| export class DataTrackSchemaStorageError< | ||
| Reason extends DataTrackSchemaStorageErrorReason = DataTrackSchemaStorageErrorReason, | ||
| > extends LivekitReasonedError<Reason> { | ||
| readonly name = 'DataTrackSchemaStorageError'; | ||
|
|
||
| reason: Reason; | ||
|
|
||
| reasonName: string; | ||
|
|
||
| constructor(message: string, reason: Reason, options?: { cause?: unknown }) { | ||
| super(24, message, options); | ||
| this.reason = reason; | ||
| this.reasonName = DataTrackSchemaStorageErrorReason[reason]; | ||
| } | ||
|
|
||
| static timeout() { | ||
| return new DataTrackSchemaStorageError( | ||
| 'Schema storage request timed out', | ||
| DataTrackSchemaStorageErrorReason.Timeout, | ||
| ); | ||
| } | ||
|
|
||
| static notFound(message: string) { | ||
| return new DataTrackSchemaStorageError( | ||
| message || 'The participant has not defined a schema with this ID', | ||
| DataTrackSchemaStorageErrorReason.NotFound, | ||
| ); | ||
| } | ||
|
|
||
| static requestFailed(reason: RequestResponse_Reason, message: string) { | ||
| return new DataTrackSchemaStorageError( | ||
| `Schema storage request failed (${RequestResponse_Reason[reason]}): ${message}`, | ||
| DataTrackSchemaStorageErrorReason.RequestFailed, | ||
| ); | ||
| } | ||
|
|
||
| static malformedResponse() { | ||
| return new DataTrackSchemaStorageError( | ||
| 'Schema storage response is malformed', | ||
| DataTrackSchemaStorageErrorReason.MalformedResponse, | ||
| ); | ||
| } | ||
|
|
||
| static invalidDefinition(options?: { cause?: unknown }) { | ||
| return new DataTrackSchemaStorageError( | ||
| 'Schema definition is not valid UTF-8', | ||
| DataTrackSchemaStorageErrorReason.InvalidDefinition, | ||
| options, | ||
| ); | ||
| } | ||
|
|
||
| // NOTE: this was introduced by web / there isn't a corresponding case in the rust version. | ||
| static cancelled() { | ||
| return new DataTrackSchemaStorageError( | ||
| 'Schema storage request cancelled by caller', | ||
| DataTrackSchemaStorageErrorReason.Cancelled, | ||
| ); | ||
| } | ||
|
|
||
| static disconnected() { | ||
| return new DataTrackSchemaStorageError( | ||
| 'Cannot store or retrieve a schema definition when disconnected', | ||
| DataTrackSchemaStorageErrorReason.Disconnected, | ||
| ); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
probably this is too late now, but curious to learn why the success path isn't using the existing
RequestResponseformat, tooThere 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.
Great question, this is because typically a
RequestResponsecontains a copy of the request. However, in this case, since the request's payload is potentially large, it didn't make sense to echo the whole thing back if there is an error.