-
Notifications
You must be signed in to change notification settings - Fork 349
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
feat: Allow simultaneous services and generic service definitions #512
Merged
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
dcdcec6
allow services and generic service definitions to be generated at the…
bb0737f
Merge remote-tracking branch 'upstream/main' into generic2
fizx 240faac
refactor to array usage
fizx 0e754ef
naming is clearer
fizx d07001e
Add M1/ARM support for the test suite
fizx 3b1d8e7
Merge branch 'm1' into generic2
fizx d50dd80
fix type
fizx b44eb98
wip
fizx 9f67b87
Merge ARM/x86 Dockerfiles
fizx 0e7098b
Merge remote-tracking branch 'upstream/main' into generic2
fizx b726d33
Merge branch 'm1' into generic2
fizx e2fe632
fix options in tests
fizx 3419a9c
revert some accidental files
fizx 51e93de
Merge remote-tracking branch 'upstream/main' into generic2
fizx 39cb74a
fix options parsing
fizx 8686103
might work
fizx 7a20968
fixup test
fizx 17baa64
clean up test
fizx 8f91bbe
drop unused option
fizx 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 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
Binary file not shown.
1 change: 1 addition & 0 deletions
1
integration/generic-service-definitions-and-services/parameters.txt
This file contains 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 @@ | ||
outputServices=generic-definitions,outputServices=generic-definitions=default |
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
integration/generic-service-definitions-and-services/simple.proto
This file contains 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,25 @@ | ||
syntax = "proto3"; | ||
|
||
package simple; | ||
|
||
service Test { | ||
option deprecated = true; | ||
|
||
rpc Unary (TestMessage) returns (TestMessage) {} | ||
rpc ServerStreaming (TestMessage) returns (stream TestMessage) {} | ||
rpc ClientStreaming (stream TestMessage) returns (TestMessage) {} | ||
rpc BidiStreaming (stream TestMessage) returns (stream TestMessage) {} | ||
rpc Deprecated (TestMessage) returns (TestMessage) { | ||
option deprecated = true; | ||
} | ||
rpc Idempotent (TestMessage) returns (TestMessage) { | ||
option idempotency_level = IDEMPOTENT; | ||
} | ||
rpc NoSideEffects (TestMessage) returns (TestMessage) { | ||
option idempotency_level = NO_SIDE_EFFECTS; | ||
} | ||
} | ||
|
||
message TestMessage { | ||
string value = 1; | ||
} |
155 changes: 155 additions & 0 deletions
155
integration/generic-service-definitions-and-services/simple.ts
This file contains 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,155 @@ | ||
/* eslint-disable */ | ||
import { util, configure, Writer, Reader } from 'protobufjs/minimal'; | ||
import * as Long from 'long'; | ||
|
||
export const protobufPackage = 'simple'; | ||
|
||
export interface TestMessage { | ||
value: string; | ||
} | ||
|
||
function createBaseTestMessage(): TestMessage { | ||
return { value: '' }; | ||
} | ||
|
||
export const TestMessage = { | ||
encode(message: TestMessage, writer: Writer = Writer.create()): Writer { | ||
if (message.value !== '') { | ||
writer.uint32(10).string(message.value); | ||
} | ||
return writer; | ||
}, | ||
|
||
decode(input: Reader | Uint8Array, length?: number): TestMessage { | ||
const reader = input instanceof Reader ? input : new Reader(input); | ||
let end = length === undefined ? reader.len : reader.pos + length; | ||
const message = createBaseTestMessage(); | ||
while (reader.pos < end) { | ||
const tag = reader.uint32(); | ||
switch (tag >>> 3) { | ||
case 1: | ||
message.value = reader.string(); | ||
break; | ||
default: | ||
reader.skipType(tag & 7); | ||
break; | ||
} | ||
} | ||
return message; | ||
}, | ||
|
||
fromJSON(object: any): TestMessage { | ||
return { | ||
value: isSet(object.value) ? String(object.value) : '', | ||
}; | ||
}, | ||
|
||
toJSON(message: TestMessage): unknown { | ||
const obj: any = {}; | ||
message.value !== undefined && (obj.value = message.value); | ||
return obj; | ||
}, | ||
|
||
fromPartial<I extends Exact<DeepPartial<TestMessage>, I>>(object: I): TestMessage { | ||
const message = createBaseTestMessage(); | ||
message.value = object.value ?? ''; | ||
return message; | ||
}, | ||
}; | ||
|
||
/** @deprecated */ | ||
export const TestDefinition = { | ||
name: 'Test', | ||
fullName: 'simple.Test', | ||
methods: { | ||
unary: { | ||
name: 'Unary', | ||
requestType: TestMessage, | ||
requestStream: false, | ||
responseType: TestMessage, | ||
responseStream: false, | ||
options: {}, | ||
}, | ||
serverStreaming: { | ||
name: 'ServerStreaming', | ||
requestType: TestMessage, | ||
requestStream: false, | ||
responseType: TestMessage, | ||
responseStream: true, | ||
options: {}, | ||
}, | ||
clientStreaming: { | ||
name: 'ClientStreaming', | ||
requestType: TestMessage, | ||
requestStream: true, | ||
responseType: TestMessage, | ||
responseStream: false, | ||
options: {}, | ||
}, | ||
bidiStreaming: { | ||
name: 'BidiStreaming', | ||
requestType: TestMessage, | ||
requestStream: true, | ||
responseType: TestMessage, | ||
responseStream: true, | ||
options: {}, | ||
}, | ||
/** @deprecated */ | ||
deprecated: { | ||
name: 'Deprecated', | ||
requestType: TestMessage, | ||
requestStream: false, | ||
responseType: TestMessage, | ||
responseStream: false, | ||
options: {}, | ||
}, | ||
idempotent: { | ||
name: 'Idempotent', | ||
requestType: TestMessage, | ||
requestStream: false, | ||
responseType: TestMessage, | ||
responseStream: false, | ||
options: { | ||
idempotencyLevel: 'IDEMPOTENT', | ||
}, | ||
}, | ||
noSideEffects: { | ||
name: 'NoSideEffects', | ||
requestType: TestMessage, | ||
requestStream: false, | ||
responseType: TestMessage, | ||
responseStream: false, | ||
options: { | ||
idempotencyLevel: 'NO_SIDE_EFFECTS', | ||
}, | ||
}, | ||
}, | ||
} as const; | ||
|
||
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined; | ||
|
||
export type DeepPartial<T> = T extends Builtin | ||
? T | ||
: T extends Array<infer U> | ||
? Array<DeepPartial<U>> | ||
: T extends ReadonlyArray<infer U> | ||
? ReadonlyArray<DeepPartial<U>> | ||
: T extends {} | ||
? { [K in keyof T]?: DeepPartial<T[K]> } | ||
: Partial<T>; | ||
|
||
type KeysOfUnion<T> = T extends T ? keyof T : never; | ||
export type Exact<P, I extends P> = P extends Builtin | ||
? P | ||
: P & { [K in keyof P]: Exact<P[K], I[K]> } & Record<Exclude<keyof I, KeysOfUnion<P>>, never>; | ||
|
||
// If you get a compile-error about 'Constructor<Long> and ... have no overlap', | ||
// add '--ts_proto_opt=esModuleInterop=true' as a flag when calling 'protoc'. | ||
if (util.Long !== Long) { | ||
util.Long = Long as any; | ||
configure(); | ||
} | ||
|
||
function isSet(value: any): boolean { | ||
return value !== null && value !== undefined; | ||
} |
This file contains 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 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 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 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
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.
Hm, kinda think, let's maybe not add a new definition and instead change
options.outServices
toServiceOption[]
?I was thinking like
outputServices=generic,default
, but,
is already taken as a separator.We could list options twice, like
outputServices=generic-definitions,outputServices=default
... I just made a fix tosnakeToCamel
that provides a precedent for how to support this "nudged to an array" pattern for options:#513
Does that seem okay?
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.
Great!