-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@artusx/plugin-grpc): add grpc support
- Loading branch information
Showing
33 changed files
with
662 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,4 @@ | ||
node_modules | ||
lib | ||
dist | ||
coverage |
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,6 @@ | ||
{ | ||
"extends": ["@artusx/eslint-config"], | ||
"parserOptions": { | ||
"project": "./tsconfig.json" | ||
} | ||
} |
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 @@ | ||
lib |
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,3 @@ | ||
registry=https://registry.npmjs.org/ | ||
always-auth=false | ||
strict-ssl=false |
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 @@ | ||
# artusx-grpc |
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,37 @@ | ||
{ | ||
"name": "artusx-grpc", | ||
"version": "0.0.0-dev.0", | ||
"description": "grpc app powered by artusx", | ||
"keywords": [ | ||
"artusx" | ||
], | ||
"author": "Suyi <[email protected]>", | ||
"main": "dist/index.js", | ||
"scripts": { | ||
"_build": "npm run tsc", | ||
"build": "", | ||
"ci": "npm run lint", | ||
"dev": "ARTUS_SERVER_ENV=development npx nodemon src/index.ts", | ||
"lint": "eslint . --ext .ts", | ||
"lint:fix": "eslint . --ext .ts --fix", | ||
"start": "ARTUS_SERVER_ENV=production node dist/index.js", | ||
"tsc": "rm -rf dist && tsc" | ||
}, | ||
"dependencies": { | ||
"@artusx/plugin-grpc": "workspace:*", | ||
"@artusx/utils": "workspace:*", | ||
"reflect-metadata": "^0.1.13", | ||
"tslib": "^2.5.0" | ||
}, | ||
"devDependencies": { | ||
"@artusx/eslint-config": "workspace:*", | ||
"@artusx/tsconfig": "workspace:*", | ||
"@types/node": "^18.11.17", | ||
"@typescript-eslint/eslint-plugin": "~6.19.1", | ||
"eslint": "~8.56.0", | ||
"eslint-plugin-import": "~2.29.1", | ||
"nodemon": "~3.0.2", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.9.4" | ||
} | ||
} |
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,11 @@ | ||
import path from 'path'; | ||
import { Application } from '@artusx/utils'; | ||
|
||
export const main = async () => { | ||
const app = await Application.start({ | ||
root: path.resolve(__dirname), | ||
configDir: 'config', | ||
}); | ||
|
||
return app; | ||
}; |
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,27 @@ | ||
import path from 'path'; | ||
|
||
export default () => { | ||
const grpc = { | ||
protoList: [ | ||
{ | ||
protoName: 'helloworld', | ||
protoPath: path.resolve(__dirname, '../protos/helloworld.proto'), | ||
serviceMap: { | ||
Greeter: { | ||
sayHello: async (call, callback) => { | ||
callback(null, { message: 'Hello ' + call.request.name }); | ||
}, | ||
}, | ||
}, | ||
}, | ||
], | ||
server: { | ||
host: '0.0.0.0', | ||
port: '50051', | ||
}, | ||
}; | ||
|
||
return { | ||
grpc, | ||
}; | ||
}; |
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 @@ | ||
export default {}; |
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 @@ | ||
export default {}; |
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,6 @@ | ||
export default { | ||
grpc: { | ||
enable: true, | ||
package: '@artusx/plugin-grpc', | ||
}, | ||
}; |
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,3 @@ | ||
import { main } from './bootstrap'; | ||
|
||
main(); |
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,45 @@ | ||
/* | ||
* | ||
* Copyright 2018 gRPC authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
syntax = "proto3"; | ||
|
||
option go_package = "google.golang.org/grpc/examples/features/proto/echo"; | ||
|
||
package grpc.examples.echo; | ||
|
||
// EchoRequest is the request for echo. | ||
message EchoRequest { | ||
string message = 1; | ||
} | ||
|
||
// EchoResponse is the response for echo. | ||
message EchoResponse { | ||
string message = 1; | ||
} | ||
|
||
// Echo is the echo service. | ||
service Echo { | ||
// UnaryEcho is unary echo. | ||
rpc UnaryEcho(EchoRequest) returns (EchoResponse) {} | ||
// ServerStreamingEcho is server side streaming. | ||
rpc ServerStreamingEcho(EchoRequest) returns (stream EchoResponse) {} | ||
// ClientStreamingEcho is client side streaming. | ||
rpc ClientStreamingEcho(stream EchoRequest) returns (EchoResponse) {} | ||
// BidirectionalStreamingEcho is bidi streaming. | ||
rpc BidirectionalStreamingEcho(stream EchoRequest) returns (stream EchoResponse) {} | ||
} |
Oops, something went wrong.