-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow simultaneous services and generic service definitions (#512)
* allow services and generic service definitions to be generated at the same time * refactor to array usage * naming is clearer * Add M1/ARM support for the test suite * fix type * wip * Merge ARM/x86 Dockerfiles * fix options in tests * revert some accidental files * fix options parsing * might work * fixup test * clean up test * drop unused option Co-authored-by: Kyle Maxwell <[email protected]>
- Loading branch information
Showing
10 changed files
with
231 additions
and
28 deletions.
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