![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
adonis-grpc-consumer
Advanced tools
Adonis gRPC client provider for easily communicate with gRPC services
npm i adonis-grpc-consumer
node ace configure adonis-grpc-consumer
First of all, you need to create a "proto" folder at the root of your Adonis project in which you will obviously store your protobuf definition files.
my-app/proto/myService.proto :
syntax = "proto3";
package my_service;
message Empty {}
service MyService {
rpc SendMessage (SendMessageRequest) returns (Empty) {};
}
message SendMessageRequest {
string message = 1;
}
Now you have to generate the type definitions for typescript. To do this, run :
npx build-proto --longs=String --enums=String --defaults --oneofs --grpcLib=@grpc/grpc-js --outDir=./proto/ ./proto/*.proto
build-proto
is an executable from @grpc/proto-loader
package ( proto-loader-gen-types
) that is embedded in adonis-grpc-consumer
.
If everything went well, in my-app/proto/ you should find your TS definition files next to your .proto file.
Now we go back to Adonis, we will add our freshly created service as a consumable service, in config/grpc-consumer.ts :
let grpcConfig: GrpcConsumerConfig = {
verbose: true,
clients: [
{
name: 'MY_SERVICE',
options: {
package: 'my_service',
serviceName: 'MyService',
protoPath: path.join(__dirname + '/../proto/myService.proto'),
url: '127.0.0.1:4545', // Don't forget to add your service url here
},
},
],
}
export default grpcConfig
Try to launch your application, in case everything went well, you should see the following message (only with verbose: true
):
[GRPC] Client MY_SERVICE connected !
To use our service and call the SendMessage
function defined in the protobuf file, we do the following:
import GrpcConsumer, { grpc } from '@ioc:Adonis/Addons/GrpcConsumer'
import { MyServiceClient } from 'proto/my_service/MyService'
const client = GrpcConsumer.getClient<MyServiceClient>('MY_SERVICE')
client.SendMessage({ message: 'hello !' }, (error?: grpc.ServiceError) => {
if (error) {
console.error(error.message)
}
}
)
FAQs
Adonis gRPC client provider for easily communicate with gRPC services
The npm package adonis-grpc-consumer receives a total of 1 weekly downloads. As such, adonis-grpc-consumer popularity was classified as not popular.
We found that adonis-grpc-consumer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.