Skip to content

lint check #2

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
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/lintCheck.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "lint protobuf"
on: [pull_request]
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bufbuild/buf-setup-action@v1

# Lint your Protobuf sources
- name: buf-lint
if: always()
uses: bufbuild/buf-lint-action@v1
with:
input: proto
# Run breaking change detection against the `main` branch
- name: buf-breaking
if: always()
uses: bufbuild/buf-breaking-action@v1
with:
against: 'https://github.com/scarshad/platform-proto-storage.git#branch=main'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
compile-tracer:
protoc -I ./instrumentation/tracer/proto \
--go_out ./instrumentation/tracer/pb --go_opt paths=source_relative \
--go-grpc_out ./instrumentation/tracer/pb --go-grpc_opt paths=source_relative \
./instrumentation/tracer/proto/*.proto
protoc -I ./proto/instrumentation/tracer/v1 \
--go_out ./pb/instrumentation/tracer/v1 --go_opt paths=source_relative \
--go-grpc_out ./pb/instrumentation/tracer/v1 --go-grpc_opt paths=source_relative \
./proto/instrumentation/tracer/v1/*.proto
8 changes: 8 additions & 0 deletions config/.protolint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
lint:
rules:
no_default: true

add:
- SERVICE_NAMES_UPPER_CAMEL_CASE
- ENUM_NAMES_UPPER_CAMEL_CASE
- ENUM_FIELD_NAMES_UPPER_SNAKE_CASE
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ require (
golang.org/x/net v0.7.0 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.7.0 // indirect
google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc // indirect
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc h1:ijGwO+0vL2hJt5gaygqP2j6PfflOBrRot0IczKbmtio=
google.golang.org/genproto v0.0.0-20230209215440-0dfe4f8abfcc/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM=
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44 h1:EfLuoKW5WfkgVdDy7dTK8qSbH37AX5mj/MFh+bGPz14=
google.golang.org/genproto v0.0.0-20230216225411-c8e22ba71e44/go.mod h1:8B0gmkoRebU8ukX6HP+4wrVQUY1+6PkQ44BSyIlflHA=
google.golang.org/grpc v1.53.0 h1:LAv2ds7cmFV/XTS3XG1NneeENYrXGmorPxsBbptIjNc=
google.golang.org/grpc v1.53.0/go.mod h1:OnIrk0ipVdj4N5d9IUoFUx72/VlD7+jUsHwZgwSMQpw=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
Expand Down
8 changes: 8 additions & 0 deletions nodejs-lib/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
## Nodejs Central Protobuf Repository

- This is a nodejs library which will expose the protobuf structure

## How a server/client can integrate it?
- run command `npm install platform-proto-storage`
- use it like a library, import it in any file and use it.

7 changes: 7 additions & 0 deletions nodejs-lib/protolib.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const grpc = require("grpc");
const protoLoader = require("@grpc/proto-loader")
const packageDef = protoLoader.loadSync("../proto/instrumentation/todo/todo.proto", {});
const grpcObject = grpc.loadPackageDefinition(packageDef);
const todoPackage = grpcObject.todoPackage;

module.exports = {todoPackage}
29 changes: 29 additions & 0 deletions nodejs-services/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const grpc = require("grpc");
const {todoPackage} = require("../nodejs-lib/protolib")

const text = process.argv[2];

const client = new todoPackage.Todo("localhost:40000",
grpc.credentials.createInsecure())
console.log(text)

client.createTodo({
"id": -1,
"text": text
}, (err, response) => {
console.log("Recieved from server " + JSON.stringify(response))

})

client.readTodos(null, (err, response) => {
console.log("read the todos from server " + JSON.stringify(response))
if (!response.items)
response.items.forEach(a=>console.log(a.text));
})

const call = client.readTodosStream();
call.on("data", item => {
console.log("received item from server " + JSON.stringify(item))
})

call.on("end", e => console.log("server done!"))
34 changes: 34 additions & 0 deletions nodejs-services/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const grpc = require("grpc");
const {todoPackage} = require("../nodejs-lib/protolib")

const server = new grpc.Server();
server.bind("0.0.0.0:40000",
grpc.ServerCredentials.createInsecure());

server.addService(todoPackage.Todo.service,
{
"createTodo": createTodo,
"readTodos" : readTodos,
"readTodosStream": readTodosStream
});
server.start();

const todos = []
function createTodo (call, callback) {
const todoItem = {
"id": todos.length + 1,
"text": call.request.text
}
todos.push(todoItem)
callback(null, todoItem);
}

function readTodosStream(call, callback) {
todos.forEach(t => call.write(t));
call.end();
}


function readTodos(call, callback) {
callback(null, {"items": todos})
}
Loading