Skip to content

Commit f119b79

Browse files
committed
Initial grpc proxy server project
1 parent 3ae42cd commit f119b79

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+49300
-0
lines changed

packages/sdk-codegen-scripts/src/reformatter.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,28 @@ class GoFormatter extends BaseFormatter {
295295
}
296296
}
297297

298+
class ProtoFormatter extends BaseFormatter {
299+
constructor() {
300+
super('Protobuf')
301+
}
302+
303+
versionStamp() {
304+
return warn('Skipping SDK version updating - not implemented for Protobuf.')
305+
}
306+
}
307+
308+
class GrpcProxyFormatter extends BaseFormatter {
309+
constructor() {
310+
super('Grpc')
311+
}
312+
313+
versionStamp() {
314+
return warn(
315+
'Skipping SDK version updating - not implemented for Grpc proxy.'
316+
)
317+
}
318+
}
319+
298320
type IFormatFiles = { [key: string]: string[] }
299321

300322
type IFormatters = { [key: string]: IReformat }
@@ -306,6 +328,8 @@ const fileFormatters: IFormatters = {
306328
'.swift': new SwiftFormatter(),
307329
'.ts': new TypescriptFormatter(),
308330
'.go': new GoFormatter(),
331+
'.proto': new ProtoFormatter(),
332+
'.java': new GrpcProxyFormatter(),
309333
}
310334

311335
export class FilesFormatter {

packages/sdk-codegen/src/codeGenerators.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import { SwiftGen } from './swift.gen'
3232
import { PythonGen } from './python.gen'
3333
import { TypescriptGen } from './typescript.gen'
3434
import { GoGen } from './go.gen'
35+
import { ProtoGen } from './proto.gen'
36+
import { GrpcProxyGen } from './grpc_proxy.gen'
3537

3638
export interface IGeneratorSpec {
3739
/** source code file extension regex */
@@ -101,6 +103,18 @@ export const Generators: Array<IGeneratorSpec> = [
101103
options: '-papiPackage=Looker -ppackageName=looker',
102104
extension: /\.php/gi,
103105
},
106+
{
107+
factory: (api: ApiModel, versions?: IVersionInfo) =>
108+
new ProtoGen(api, versions),
109+
language: 'Protobuf',
110+
extension: /\.proto/gi,
111+
},
112+
{
113+
factory: (api: ApiModel, versions?: IVersionInfo) =>
114+
new GrpcProxyGen(api, versions),
115+
language: 'GrpcProxy',
116+
extension: /\.java/gi,
117+
},
104118
// {
105119
// language: 'R',
106120
// legacy: 'r'
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
3+
MIT License
4+
5+
Copyright (c) 2020 Looker Data Sciences, Inc.
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy
8+
of this software and associated documentation files (the "Software"), to deal
9+
in the Software without restriction, including without limitation the rights
10+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11+
copies of the Software, and to permit persons to whom the Software is
12+
furnished to do so, subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23+
SOFTWARE.
24+
25+
*/
26+
27+
import { TestConfig } from './testUtils'
28+
import { GrpcProxyGen } from './grpc_proxy.gen'
29+
30+
const config = TestConfig()
31+
const apiTestModel = config.apiTestModel
32+
33+
const gen = new GrpcProxyGen(apiTestModel)
34+
35+
describe('pseudocode', () => {
36+
describe('method signature', () => {
37+
it('optional body and additional param', () => {
38+
const method = apiTestModel.methods.create_user_credentials_email
39+
expect(method).toBeDefined()
40+
const expected = `create_user_credentials_email(user_id, body, fields): CredentialsEmail`
41+
const actual = gen.methodSignature('', method)
42+
expect(actual).toEqual(expected)
43+
})
44+
it('no params', () => {
45+
const method = apiTestModel.methods.all_datagroups
46+
expect(method).toBeDefined()
47+
const expected = `all_datagroups(): Datagroup[]`
48+
const actual = gen.methodSignature('', method)
49+
expect(actual).toEqual(expected)
50+
})
51+
})
52+
})

0 commit comments

Comments
 (0)