question
stringlengths
11
28.2k
answer
stringlengths
26
27.7k
tag
stringclasses
130 values
question_id
int64
935
78.4M
score
int64
10
5.49k
To facilitate working with Avro in Scala, I'd like to define a case class based on the schema stored with a .avro file. I could try: Writing a .scala case class definition by hand. Programmatically writing strings to a .scala file Spoof the case class definition with a bytecode library like ObjectWeb's ASM Specifi...
I've been hacking on a little project called Scalavro to go the other way (Scala types to Avro schemas). It also gives you direct binary I/O. Simple Example: package com.gensler.scalavro.tests import com.gensler.scalavro.types.AvroType case class Person(name: String, age: Int) val personAvroType = AvroType[Person] p...
Avro
15,607,038
17
I am writing a spark job using python. However, I need to read in a whole bunch of avro files. This is the closest solution that I have found in Spark's example folder. However, you need to submit this python script using spark-submit. In the command line of spark-submit, you can specify the driver-class, in that case...
Spark >= 2.4.0 You can use built-in Avro support. The API is backwards compatible with the spark-avro package, with a few additions (most notably from_avro / to_avro function). Please note that module is not bundled with standard Spark binaries and has to be included using spark.jars.packages or equivalent mechanism. S...
Avro
29,759,893
17
I am new to Hadoop and programming, and I am a little confused about Avro schema evolution. I will explain what I understand about Avro so far. Avro is a serialization tool that stores binary data with its json schema at the top. The schema looks like this. { "namespace":"com.trese.db.model", "type":"record", ...
If you have one avro file and you want to change its schema, you can rewrite that file with a new schema inside. But what if you have terabytes of avro files and you want to change their schema? Will you rewrite all of the data, every time the schema changes? Schema evolution allows you to update the schema used to wri...
Avro
39,135,471
17
According to this question on nesting Avro schemas, the right way to nest a record schema is as follows: { "name": "person", "type": "record", "fields": [ {"name": "firstname", "type": "string"}, {"name": "lastname", "type": "string"}, { "name": "address", "ty...
Can I give the field and schema the same name, address? Yes, you can name the record with the same name as the field name. What if I want to use the AddressUSRecord schema in multiple other schemas, not just person? You can use multiple schemas using a couple of techniques: the avro schema parser clients (JVM and ...
Avro
40,854,529
17
I have some json data that looks like this: { "id": 1998983092, "name": "Test Name 1", "type": "search string", "creationDate": "2017-06-06T13:49:15.091+0000", "lastModificationDate": "2017-06-28T14:53:19.698+0000", "lastModifiedUsername": "testuser@test.com", "lockedQuery": false, "lo...
To be able to set Avro field to null you should allow this in Avro schema, by adding null as one of the possible types of the field. Take a look on example from Avro documentation: { "type": "record", "name": "MyRecord", "fields" : [ {"name": "userId", "type": "long"}, // mandatory field {"na...
Avro
45,662,469
17
I have a JSON document that I would like to convert to Avro and need a schema to be specified for that purpose. Here is the JSON document for which I would like to define the avro schema: { "uid": 29153333, "somefield": "somevalue", "options": [ { "item1_lvl2": "a", "item2_lvl2": [ { "it...
You need to use Avro complex types, specifically arrays and records. And then nest these together: { "namespace" : "my.com.ns", "name": "myrecord", "type" : "record", "fields" : [ {"name": "uid", "type": "int"}, {"name": "somefield", "type": "string"}, {"name": "options", "type": { "type...
Avro
28,163,225
16
Is the Avro SpecificRecord (i.e. the generated java classes) compatible with schema evolution? I.e. if I have a source of Avro messages (in my case, kafka) and I want to deserialize those messages to a specificrecord, is it possible to do safely? What I see: adding a field to the end of a schema works fine - can dese...
There are example tests here for specific data type conversion. Its all in the configuration 'specificDeserializerProps' https://github.com/confluentinc/schema-registry/blob/master/avro-serializer/src/test/java/io/confluent/kafka/serializers/KafkaAvroSerializerTest.java I added the following config and got the specifi...
Avro
33,945,383
16
I am trying to create a Kafka Streams Application which processes Avro records, but I am getting the following error: Exception in thread "streams-application-c8031218-8de9-4d55-a5d0-81c30051a829-StreamThread-1" org.apache.kafka.streams.errors.StreamsException: Deserialization exception handler is set to fail upon a de...
Unknown magic byte! Means your data does not adhere to the wire format that's expected for the Schema Registry. Or, in other words, the data you're trying to read, is not Avro, as expected by the Confluent Avro deserializer. You can expect the same error by running kafka-avro-console-consumer, by the way, so you ma...
Avro
53,835,446
16
If I serialize an object using a schema version 1, and later update the schema to version 2 (say by adding a field) - am I required to use schema version 1 when later deserializing the object? Ideally I would like to just use schema version 2 and have the deserialized object have the default value for the field that wa...
Avro and Protocol Buffers have different approaches to handling versioning, and which approach is better depends on your use case. In Protocol Buffers you have to explicitly tag every field with a number, and those numbers are stored along with the fields' values in the binary representation. Thus, as long as you never...
Avro
12,165,589
15
i.e. is it possible to make field required similar to ProtoBuf: message SearchRequest { required string query = 1; }
All fields are required in Avro by default. As is mentioned in the official documentation, if you want to make something optional, you have to make it nullable by unioning its type with null, like this { "namespace": "example.avro", "type": "record", "name": "User", "fields": [ {"name": "name", "type": "stri...
Avro
31,995,145
15
I need to mix "record" type with null type in Schema. "name":"specShape", "type":{ "type":"record", "name":"noSpecShape", "fields":[ { "name":"bpSsc", "type":"null", "default":null, "doc"...
You had the right idea, you just need to include "null" in the higher level "type" array instead of inside the "fields" array (as in your third example). This is the schema for a nullable record: [ "null", { "type": "record", "name": "NoSpecShape", "fields": [ { "type": "null", "na...
Avro
36,321,616
15
My KafkaProducer is able to use KafkaAvroSerializer to serialize objects to my topic. However, KafkaConsumer.poll() returns deserialized GenericRecord instead of my serialized class. MyKafkaProducer KafkaProducer<CharSequence, MyBean> producer; try (InputStream props = Resources.getResource("producer.props").openS...
KafkaAvroDeserializer supports SpecificData It's not enabled by default. To enable it: properties.put(KafkaAvroDeserializerConfig.SPECIFIC_AVRO_READER_CONFIG, true); KafkaAvroDeserializer does not support ReflectData Confluent's KafkaAvroDeserializer does not know how to deserialize using Avro ReflectData. I had to ex...
Avro
39,606,026
15
I am trying to create Union field in Avro schema and send corresponding JSON message with it but to have one of the fields - null. https://avro.apache.org/docs/1.8.2/spec.html#Unions What is example of simplest UNION type (avro schema) with corresponding JSON data? (trying to make example without null/empty data and on...
Here you have an example. Null enum {"name": "Stephanie", "age": 30, "sex": "female", "myenum": null} Not null enum {"name": "Stephanie", "age": 30, "sex": "female", "myenum": "HEARTS"} Schema { "type": "record", "name": "Test", "namespace": "com.acme", "fields": [{ "name": "name", ...
Avro
50,283,736
15
I would like to use the kafka-avro-console-producer with the schema registry. I have big schemas (over 10k chars) and I can't really past them as a command line argument. Besides that I'd like to use the schema registry directly so I can use a specific schema id. I'm thinking about something like this, but it doesn't ...
For the current version of the CLI tool kafka-avro-console-producer \ --broker-list <broker-list> \ --topic <topic> \ --property schema.registry.url=http://localhost:8081 \ --property value.schema.id=419 For older version You'll need to extract the schema from the API request using jq, for example value.schema="$...
Avro
59,582,230
15
There are a lot of questions and answers on stackoverflow on the subject, but no one that helps. I have a schema with optional value: { "type" : "record", "name" : "UserSessionEvent", "namespace" : "events", "fields" : [ { "name" : "username", "type" : "string" }, { "name" : "errorData", "type" : [ "nu...
case 1 is working fine in java . { "username" : "2271AE67-34DE-4B43-8839-07216C5D10E1", "errorData" : { "string":"070226AC-9B91-47CE-85FE-15AA17972298"} } for case 2 Your schema is defined for union. You can update you schema as below to deserialize json. { "username" : "2271AE67-34DE-4B43-8839-07216C5D10E1", ...
Avro
38,824,456
14
Is there a way to use a schema to convert avro messages from kafka with spark to dataframe? The schema file for user records: { "fields": [ { "name": "firstName", "type": "string" }, { "name": "lastName", "type": "string" } ], "name": "user", "type": "record" } And code snippets from SqlNetworkWordCoun...
Please take a look at this https://github.com/databricks/spark-avro/blob/master/src/test/scala/com/databricks/spark/avro/AvroSuite.scala So instead of val df = rdd.map(message => Injection.injection.invert(message._2).get) .map(record => User(record.get("firstName").toString,records.get("lastName").toString)).toDF()...
Avro
39,049,648
14
There are at least two different ways of creating a hive table backed with Avro data: Creating a table based on an Avro schema (in this example, stored in hdfs): CREATE TABLE users_from_avro_schema ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro....
I decided to publish a complementary answer to those given by @DuduMarkovitz. To make code examples more concise let's clarify that STORED AS AVRO clause is an equivalent of these three lines: ROW FORMAT SERDE 'org.apache.hadoop.hive.serde2.avro.AvroSerDe' STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.avro.AvroCo...
Avro
44,256,427
14
I am trying to use the avro-gradle-plugin on github, but have not gotten any luck getting it to work. Does anyone have any sample code on how they get it to work?
I figured out how to do it myself. The following is a snippet that I would like to share for people who might run into the same issues as I did: apply plugin: 'java' apply plugin: 'avro-gradle-plugin' sourceCompatibility = "1.6" targetCompatibility = "1.6" buildscript { repositories { maven { // your ma...
Avro
13,351,334
13
I am using Apache avro for data serialization. Since, the data has a fixed schema I do not want the schema to be a part of serialized data. In the following example, schema is a part of the avro file "users.avro". User user1 = new User(); user1.setName("Alyssa"); user1.setFavoriteNumber(256); User user2 = new User("Be...
Here you find a comprehensive how to in which I explain how to achieve the schema-less serialization using Apache Avro. A companion test campaign shows up some figures on the performance that you might expect. The code is on GitHub: example and test classes show up how to use the Data Reader and Writer with a Stub cl...
Avro
28,808,479
13
I have this avro schema { "namespace": "xx.xxxx.xxxxx.xxxxx", "type": "record", "name": "MyPayLoad", "fields": [ {"name": "filed1", "type": "string"}, {"name": "filed2", "type": "long"}, {"name": "filed3", "type": "boolean"}, { "name" : "metrics", "type": { ...
finally i got this working. I need to give both the schemas in the SpecificDatumReader So i modified the parsing like this where i passed both the old and new schema in the reader and it worked like a charm public static final MyPayLoad parseBinaryPayload(byte[] payload) { DatumReader<MyPayLoad> payloadReader =...
Avro
34,733,604
13
Avro schemas are defined using JSON. Schemas are composed of primitive types (null, boolean, int, long, float, double, bytes, and string) and complex types (record, enum, array, map, union, and fixed). I want to ask which one is proper for BigDecimal.
Avro introduced logical types in 1.7.7 (I believe) that should help you serialize decimal. https://avro.apache.org/docs/1.8.1/spec.html#Decimal
Avro
38,213,063
13
With the Avro Java API, I can make a simple record schema like: Schema schemaWithTimestamp = SchemaBuilder .record("MyRecord").namespace("org.demo") .fields() .name("timestamp").type().longType().noDefault() .endRecord(); How do I tag a schema field with a logical ty...
Thanks to DontPanic: Schema timestampMilliType = LogicalTypes.timestampMillis().addToSchema(Schema.create(Schema.Type.LONG)); Schema schemaWithTimestamp = SchemaBuilder .record("MyRecord").namespace("org.demo") .fields() .name("timestamp_with_logical_type").type(timestampMil...
Avro
43,080,894
13
I have been trying to connect with kafka-avro-console-consumer from Confluent to our legacy Kafka cluster, which was deployed without Confluent Schema Registry. I provided schema explicitly using properties like: kafka-console-consumer --bootstrap-server kafka02.internal:9092 \ --topic test \ --from-beginning ...
The Confluent Schema Registry serialiser/deserializer uses a wire format which includes information about the schema ID etc in the initial bytes of the message. If your message has not been serialized using the Schema Registry serializer, then you won't be able to deserialize it with it, and will get the Unknown magic...
Avro
52,399,417
13
I have this exception in the consumer when trying to cast the record.value() into java object : ClassCastException: class org.apache.avro.generic.GenericData$Record cannot be cast to class [...].PublicActivityRecord (org.apache.avro.generic.GenericData$Record and [...].PublicActivityRecord are in unnamed module of loa...
By default, only generic records are returned. You'll need to set value.deserializer.specific.avro.reader=true Or, use the constant in your consumer configs KafkaAvroDeserializerConfig.SPECIFIC_AVRO_READER_CONFIG = true
Avro
70,919,159
13
We are using kafka for storing messages and pushing an extremely large number of messages(> 30k in a minute). I am not sure if its relevant but the code that is the producer of the kafka message is in jruby. Serialising and Deserialising the messages also has a performance impact on the system. Can someone help with c...
I hate to tell you this, but there is no simple answer to your question. The performance of a serialization format depends on many factors. First of all, performance is a property of implementation more than of the format itself. What you really want to know is how well do the specific JRuby implementations of each for...
Avro
38,174,180
12
I'm trying to use this avro shcema { "namespace": "nothing", "name": "myAvroSchema", "type": "record", "fields": [ { "name": "checkInCustomerReference", "type": "string" }, { "name": "customerContacts", "type": "record", "fields": [ { "name": "customer...
The type of the "customerContacts" field must be a defined name or a {"type": ...} expression Doesn't look like your defining your nested records properly. I reproduced your schema and came out with this, give it a try: { "type":"record", "name":"myAvroSchema", "namespace":"nothing", "fields":[ ...
Avro
43,513,140
12
What is the correct way to create avro schema for object with array of strings? I am trying to create avro schema to object that have array of strings according to official documenation? but I get error. https://avro.apache.org/docs/1.8.1/spec.html [ERROR] Failed to execute goal org.apache.avro:avro-maven-plugin:1.8.2...
Think this should work: { "name":"parameters", "type": { "type": "array", "items": "string" } }
Avro
54,093,898
12
I have a spring application that is my kafka producer and I was wondering why avro is the best way to go. I read about it and all it has to offer, but why can't I just serialize my POJO that I created myself with jackson for example and send it to kafka? I'm saying this because the POJO generation from avro is not so ...
You don't need AVSC, you can use an AVDL file, which basically looks the same as a POJO with only the fields @namespace("com.example.mycode.avro") protocol ExampleProtocol { record User { long id; string name; } } Which, when using the idl-protocol goal of the Maven plugin, will create this AVSC for yo...
Avro
54,195,813
12
We have a glue crawler that read avro files in S3 and create a table in glue catalog accordingly. The thing is that we have a column named 'foo' that came from the avro schema and we also have something like 'foo=XXXX' in the s3 bucket path, to have Hive partitions. What we did not know is that the crawler will then c...
Glue Crawlers are pretty terrible, this is just one of the many ways where it creates unusable tables. I think you're better off just creating the tables and partitions with a simple script. Create the table without the foo column, and then write a script that lists your files on S3 do the Glue API calls (BatchCreatePa...
Avro
59,268,673
12
Is there a way to convert a JSON string to an Avro without a schema definition in Python? Or is this something only Java can handle?
I recently had the same problem, and I ended up developing a python package that can take any python data structure, including parsed JSON and store it in Avro without a need for a dedicated schema. I tested it for python 3. You can install it as pip3 install rec-avro or see the code and docs at https://github.com/bmiz...
Avro
22,382,636
11
I am running CDH 4.4 with Spark 0.9.0 from a Cloudera parcel. I have a bunch of Avro files that were created via Pig's AvroStorage UDF. I want to load these files in Spark, using a generic record or the schema onboard the Avro files. So far I've tried this: import org.apache.avro.mapred.AvroKey import org.apache.avro.m...
To answer my own question: import org.apache.spark.SparkContext import org.apache.spark.SparkContext._ import org.apache.avro.generic.GenericRecord import org.apache.avro.mapred.AvroKey import org.apache.avro.mapred.AvroInputFormat import org.apache.avro.mapreduce.AvroKeyInputFormat import org.apache.hadoop.io.NullWri...
Avro
23,944,615
11
Im trying to merge avro files into one big file, the problem is concat command does not accept the wildcard hadoop jar avro-tools.jar concat /input/part* /output/bigfile.avro I get: Exception in thread "main" java.io.FileNotFoundException: File does not exist: /input/part* I tried to use "" and '' but no chance.
I quickly checked Avro's source code (1.7.7) and it seems that concat does not support glob patterns (basically, they call FileSystem.open() on each argument except the last one). It means that you have to explicitly provide all the filenames as argument. It is cumbersome, but following command should do what you want:...
Avro
34,856,838
11
When I attempted to run Kafka Consumer with Avro over the data with my respective schema,it returns an error of "AvroRuntimeException: Malformed data. Length is negative: -40" . I see others have had similar issues converting byte array to json, Avro write and read, and Kafka Avro Binary *coder. I have also referenced ...
Perhaps the problem is a mismatch between how the Avro data is written (encoded) by Nifi vs. how your consumer app is reading (decoding) the data. In a nutshell, Avro's API provides two different approaches to serialization: For creating proper Avro files: To encode the data records but also to embed the Avro schema...
Avro
36,022,358
11
I am curious to understand the best practice for encoding one very specific type of data within Avro: UUIDs.
Here's how I've been doing it: { "name": "user_id", "type": "string", "logicalType": "UUID" } At the time of writing the logicalType for UUIDs is not documented but it is nonetheless supported, you can check the code here and verify so yourself: https://github.com/apache/avro/blob/branch-1.8/lang/java/avro...
Avro
16,339,441
10
We’re trying to decide between providing generic vs specific record formats for consumption by our clients with an eye to providing an online schema registry clients can access when the schemas are updated. We expect to send out serialized blobs prefixed with a few bytes denoting the version number so schema retrieval ...
What you are looking for is Confluent Schema registry service and libs which helps to integrate with this. Providing a sample to write Serialize De-serialize avro data with a evolving schema. Please note providing sample from Kafka. import io.confluent.kafka.serializers.KafkaAvroDeserializer; import io.confluent.kaf...
Avro
33,882,095
10
I am new to AVRO and please excuse me if it is a simple question. I have a use case where I am using AVRO schema for record calls. Let's say I have avro schema { "name": "abc", "namepsace": "xyz", "type": "record", "fields": [ {"name": "CustId", "type":"string"}, {"name": "SessionId", "...
You should be able to use a custom logical type for this. You would then include the regular expressions directly in the schema. For example, here's how you would implement one in JavaScript: var avro = require('avsc'), util = require('util'); /** * Sample logical type that validates strings using a regular expre...
Avro
37,279,096
10
I am evaluating using Apache AVRO for my Jersey REST services. I am using Springboot with Jersey REST. Currently I am accepting JSON as input which are converted to Java Pojos using the Jackson object mapper. I have looked in different places but I cannot find any example that is using Apache AVRO with a Jersey end p...
To start , two things need to happen: You need to develop a custom ObjectMapper after the fashion of the Avro schema format You need to supply that custom ObjectMapper to Jersey. That should look something like this: @Provider public class AvroMapperProvider implements ContextResolver<ObjectMapper> { final AvroM...
Avro
45,898,453
10
I recently had a requirement where I needed to generate Parquet files that could be read by Apache Spark using only Java (Using no additional software installations such as: Apache Drill, Hive, Spark, etc.). The files needed to be saved to S3 so I will be sharing details on how to do both. There were no simple to follo...
Disclaimer: The code samples below in no way represent best practices and are only presented as a rough how-to. Dependencies: parquet-avro (1.9.0) : https://mvnrepository.com/artifact/org.apache.parquet/parquet-avro/1.9.0 (We use 1.9.0 because this version uses Avro 1.8+ which supports Decimals and Dates) hadoop-aws (...
Avro
47,355,038
10
I need to be able to mark some fields in the AVRO schema so that they will be encrypted at serialization time. A logicalType allows to mark the fields, and together with a custom conversion should allow to let them be encrypted transparently by AVRO. I had some issues to find documentation on how to define and use a n...
First of all I defined a logicalType as: public class EncryptedLogicalType extends LogicalType { //The key to use as a reference to the type public static final String ENCRYPTED_LOGICAL_TYPE_NAME = "encrypted"; EncryptedLogicalType() { super(ENCRYPTED_LOGICAL_TYPE_NAME); } @Override pu...
Avro
49,034,266
10
How to use Spring-Kafka to read AVRO message with Confluent Schema registry? Is there any sample? I can't find it in official reference document.
Below code can read the message from customer-avro topic. Here's the AVRO schema on value i have defined as. { "type": "record", "namespace": "com.example", "name": "Customer", "version": "1", "fields": [ { "name": "first_name", "type": "string", "doc": "First Name of Customer" }, ...
Avro
51,979,389
10
I would like to add HTTPS to my local domain, however we can't do this on localhost. My website goes fine when I run with this Caddyfile localhost:2020 { bind {$ADDRESS} proxy / http://192.168.100.82:9000 { transparent } } But I would like to name this website or at least enable HTTPS on it. According to Ca...
For caddy version 2.4.5, the accepted answer did not work me. What worked is shown below: localhost:443 { reverse_proxy 127.0.0.1:8080 tls internal }
Caddy
39,015,159
17
I have a config file for Caddy v2 like in below: sentry.mydomain.ru { reverse_proxy sentry:9000 } tasks.mydomain.ru { reverse_proxy taiga-proxy:80 } ain.mydomain.ru { reverse_proxy ain-frontend:80 } Caddy makes https for every domain but I need to make disable "https" only for ain.mydomain.ru. How to do ...
Caddy serves http traffic only if you prefix the domain with http scheme. Here is the modified Caddyfile: sentry.mydomain.ru { reverse_proxy sentry:9000 } tasks.mydomain.ru { reverse_proxy taiga-proxy:80 } http://ain.mydomain.ru { reverse_proxy ain-frontend:80 } Reference: https://caddy.community/t/is-th...
Caddy
62,896,495
16
I'm using systemd to start a caddy webserver on an ubuntu 16.04 machine. Whenever I run sudo service caddy start and service caddy status, I get this error: ● caddy.service - Caddy webserver Loaded: loaded (/etc/systemd/system/caddy.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) si...
In my /etc/systemd/system/caddy.service file, I had the following line: Restart=on-failure Commenting that out (with # or ;) and restarting the service showed the underlying problem, which was in my Caddyfile. EDIT: service caddy status only prints a few lines from the log, so sometimes you can find the underlying...
Caddy
39,202,644
11
"By default, Caddy will bind to ports 80 and 443 to serve HTTPS and redirect HTTP to HTTPS." (https://caddyserver.com/docs/automatic-https) How can we change this port? Background: In our setup, Caddy runs behind an AWS load balancer which forwards requests from port 443 to port 4443. Therefore, we would like to have C...
According to the documentation: The first line of the Caddyfile is always the address of the site to serve. In your Caddyfile: <domain>:<port> Example: localhost:8080
Caddy
51,209,710
11
I wanted to try out Caddy in a docker environment but it does not seem to be able to connect to other containers. I created a network "caddy" and want to run a portainer alongside it. If I go into the volume of caddy, I can see, that there are certs generated, so that seems to work. Also portainer is running and access...
I just got help from the forum and it turns out, that caddy redirects to the port INSIDE the container, not the public one. In my case, portainer runs on 80 internally, so changing the Caddyfile to this: smallhetzi.fading-flame.com { reverse_proxy portainer:80 } or this smallhetzi.fading-flame.com { reverse_pr...
Caddy
68,918,079
11
I'm recently using gRPC with proto3, and I've noticed that required and optional has been removed in new syntax. Would anyone kindly explain why required/optional are removed in proto3? Such kind of constraints just seem necessary to make definition robust. syntax proto2: message SearchRequest { required string query...
The usefulness of required has been at the heart of many a debate and flame war. Large camps have existed on both sides. One camp liked guaranteeing a value was present and was willing to live with its limitations but the other camp felt required dangerous or unhelpful as it can't be safely added nor removed. Let me ex...
gRPC
31,801,257
387
Does the rpc syntax in proto3 allow null requests or responses? e.g. I want the equivalent of the following: rpc Logout; rpc Status returns (Status); rpc Log (LogData); Or should I just create a null type? message Null {}; rpc Logout (Null) returns (Null); rpc Status (Null) returns (Status); rpc Log (LogData) returns...
Kenton's comment below is sound advice: ... we as developers are really bad at guessing what we might want in the future. So I recommend being safe by always defining custom params and results types for every method, even if they are empty. Answering my own question: Looking through the default proto files, I came a...
gRPC
31,768,665
236
I try to understand protobuf and gRPC and how I can use both. Could you help me understand the following: Considering the OSI model what is where, for example is Protobuf at layer 4? Thinking through a message transfer how is the "flow", what is gRPC doing what protobuf misses? If the sender uses protobuf can the serv...
Protocol buffers is (are?) an Interface Definition Language and serialization library: You define your data structures in its IDL i.e. describe the data objects you want to use It provides routines to translate your data objects to and from binary, e.g. for writing/reading data from disk gRPC uses the same IDL but ad...
gRPC
48,330,261
218
The goal is to introduce a transport and application layer protocol that is better in its latency and network throughput. Currently, the application uses REST with HTTP/1.1 and we experience a high latency. I need to resolve this latency problem and I am open to use either gRPC(HTTP/2) or REST/HTTP2. HTTP/2: Multiplex...
gRPC is not faster than REST over HTTP/2 by default, but it gives you the tools to make it faster. There are some things that would be difficult or impossible to do with REST. Selective message compression. In gRPC a streaming RPC can decide to compress or not compress messages. For example, if you are streaming mi...
gRPC
44,877,606
155
I'm reading this explanation of GRPC and this diagram is of interest: How does the transport layer work? If it's over the network... why is it called an RPC? More importantly, how is this different from REST that implements an API for the service-layer (the class in the client that has methods that make a http request...
The transport layer works using HTTP/2 on top of TCP/IP. It allows for lower latency (faster) connections that can take advantage of a single connection from client to server (which makes more efficient use of connection and can result in more efficient use of server resources. HTTP/2 also supports bidirectional connec...
gRPC
43,682,366
114
I'd like to test a gRPC service written in Go. The example I'm using is the Hello World server example from the grpc-go repo. The protobuf definition is as follows: syntax = "proto3"; package helloworld; // The greeting service definition. service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns ...
I think you're looking for the google.golang.org/grpc/test/bufconn package to help you avoid starting up a service with a real port number, but still allowing testing of streaming RPCs. import "google.golang.org/grpc/test/bufconn" const bufSize = 1024 * 1024 var lis *bufconn.Listener func init() { lis = bufconn....
gRPC
42,102,496
99
I am trying to build a sample application with Go gRPC, but I am unable to generate the code using "protoc" I have installed the required libraries and Go packages using: go get -u google.golang.org/grpc go get -u github.com/golang/protobuf/protoc-gen-go I have tried setting the path as well, but no luck. Sample "pro...
Go 1.17+ From https://go.dev/doc/go-get-install-deprecation Starting in Go 1.17, installing executables with go get is deprecated. go install may be used instead. ~/.bashrc export GOPATH=$HOME/go export PATH=$PATH:$GOPATH/bin Install go install google.golang.org/protobuf/cmd/protoc-gen-go@latest go: downloading go...
gRPC
57,700,860
96
We want to build a Javascript/HTML gui for our gRPC-microservices. Since gRPC is not supported on the browser side, we thought of using web-sockets to connect to a node.js server, which calls the target service via grpc. We struggle to find an elegant solution to do this. Especially, since we use gRPC streams to push ...
Edit: Since Oct 23,2018 the gRPC-Web project is Generally Available, which might be the most official/standardized way to solve your problem. (Even if it's already 2018 now... ;) ) From the GA-Blog: "gRPC-Web, just like gRPC, lets you define the service “contract” between client (web) and backend gRPC services using Pr...
gRPC
35,065,875
85
I am getting error while installing grpcio using pip install grpcio on my windows machine.I read here - https://github.com/grpc/grpc/issues/17829 that it may be due to error in a version of setuptools. I upgraded my setuptools to the latest version i.e. 41.0.1 . Still getting the same build error. Its not happening for...
First, upgrade pip pip3 install --upgrade pip Then, update the setup tools: python3 -m pip install --upgrade setuptools At last, install grpcio using : pip3 install --no-cache-dir --force-reinstall -Iv grpcio==<version_number>
gRPC
56,357,794
79
What is the pattern for sending more details about errors to the client using gRPC? For example, suppose I have a form for registering a user, that sends a message message RegisterUser { string email = 1; string password = 2; } where the email has to be properly formatted and unique, and the password must be at le...
Include additional error details in the response Metadata. However, still make sure to provide a useful status code and message. In this case, you can add RegisterUserResponse to the Metadata. In gRPC Java, that would look like: Metadata.Key<RegisterUserResponse> REGISTER_USER_RESPONSE_KEY = ProtoUtils.keyForProto(...
gRPC
48,748,745
58
go version: go version go1.14 linux/amd64 go.mod module [redacted] go 1.14 require ( github.com/golang/protobuf v1.4.0-rc.2 google.golang.org/grpc v1.27.1 google.golang.org/protobuf v1.20.0 // indirect ) I am running the following command: protoc -I ./src/pbdefs/protos/ --go-grpc_out=. src/pbdefs/protos/...
the missing plugin has been implemented at https://github.com/grpc/grpc-go. command below should fix it go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
gRPC
60,578,892
49
I am attempting to import one protocol buffer message into another, but the imports are not recognized. As long as I don't try to import one protobuf into another, the protobuf code is generated (in java), the code compiles and runs as expected. I'm using: Intellij Idea 2020 v1.3 Unlimited Edition Protobuf Editor plug...
Take a look at the readme which describes how to add additional paths. By default, intellij-protobuf-editor uses the project's configured source roots as protobuf import paths. If this isn't correct, you can override these paths in Settings > Languages & Frameworks > Protocol Buffers. Uncheck "Configure automatically" ...
gRPC
62,837,953
44
I recently started reading and employing gRPC in my work. gRPC uses protocol-buffers internally as its IDL and I keep reading everywhere that protocol-buffers perform much better, faster as compared to JSON and XML. What I fail to understand is - how do they do that? What design in protocol-buffers actually makes them ...
String representations of data: require text encode/decode (which can be cheap, but is still an extra step) requires complex parse code, especially if there are human-friendly rules like "must allow whitespace" usually involves more bandwidth - so more actual payload to churn - due to embedding of things like names, a...
gRPC
52,146,721
40
According to documentation: deprecated (field option): If set to true, indicates that the field is deprecated and should not be used by new code. Example of use: message Foo { string old_field = 1 [deprecated=true]; } How we can deprecate the whole message?
You can set deprecated as a top level option on the message: message Foo { option deprecated = true; string old_field = 1; }
gRPC
52,781,727
36
I want to create a simple gRPC endpoint which the user can upload his/her picture. The protocol buffer declaration is the following: message UploadImageRequest { AuthToken auth = 1; // An enum with either JPG or PNG FileType image_format = 2; // Image file as bytes bytes image = 3; } Is this approa...
For large binary transfers, the standard approach is chunking. Chunking can serve two purposes: reduce the maximum amount of memory required to process each message provide a boundary for recovering partial uploads. For your use-case #2 probably isn't very necessary. In gRPC, a client-streaming call allows fo...
gRPC
34,969,446
34
Good evening everyone, I have only been dealing with Java and Android Studio for a few months, can someone help me to solve this error? It occurs every time the emulator starts. Thank you Emulator: Started GRPC server at 127.0.0.1:8554 Emulator: emulator: WARNING: EmulatorService.cpp:448: Cannot find certfile: C:\User...
A quick fix: From the main navbar menu Tools > Android > SDK Manager > Android SDK > SDK Tools You'll then see the screen below where you can select '- Android Emulator Hypervisor Driver for AMD Processors (installer) version 1.3.0' I am not sure what the actual root cause of the issue is, but this patched the issue f...
gRPC
60,306,645
33
I have a go grpc service. I'm developing on a mac, sierra. When running a grpc client against the service locally, all is well, but when running same client against same service in the docker container I get this error: transport: http2Client.notifyError got notified that the client transport was broken EOF. FATA[0000]...
When you specify a hostname or IP address​ to listen on (in this case localhost which resolves to 127.0.0.1), then your server will only listen on that IP address. Listening on localhost isn't a problem when you are outside of a Docker container. If your server only listens on 127.0.0.1:51672, then your client can eas...
gRPC
43,911,793
32
Let's consider a simple service: service Something { rpc Do(Request) returns Response; } message Request { string field = 1; } message Response { string response = 1; } Assume I have to do some checking on the Request.field, I want to raise a client error if the field is invalid: class MyService(proto_p...
Yes, there is a better way. You may change the status details using the ServicerContext.set_details method and you may change the status code using the ServicerContext.set_code method. I suspect that your servicer will look something like class MyService(proto_pb2.SomethingServicer): def Do(self, request, context)...
gRPC
40,998,199
31
I have a reasonable experience in developing both SOAP and REST web services (in java platform). I am trying to understand the difference between the gRPC and CORBA in every aspect apart from the fact that both enables platform-neutral way of communication in distributed environment. where and how is the Goal/Purpose o...
gRPC and CORBA share very similar concepts and building blocks: Client/Server architecture with Interface Definition Language (IDL) to generate client Stubs and server Skeletons, standard data interchangeable format and bindings for multiple programming languages. CORBA uses the OMG's IDL for defining object interfaces...
gRPC
44,452,399
30
Hey I'm trying make a small test client with Go and Grpc, opts := grpc.WithInsecure() cc, err := grpc.Dial("localhost:9950", opts) if err != nil { log.Fatal(err) } The WithInsecure() function call gives a warning: grpc.WithInsecure is deprecated: use insecure.NewCredentials() instead. I'm not sur...
The function insecure.NewCredentials returns an implementation of credentials.TransportCredentials. You can use it as a DialOption with grpc.WithTransportCredentials: grpc.Dial(":9950", grpc.WithTransportCredentials(insecure.NewCredentials()))
gRPC
70,482,508
29
I have been trying for 3 days by now to find how to install and use gRPC on windows with no luck. I am using Visual Studio 2015, Win7 64-bit. To be safe, I'll write step by step of what I am doing. It might not be necessary but I am a beginner with C++ and with VS so I am not at all sure I am doing it correctly: (fol...
After struggling with this for some time myself, I found that vcpkg does a very good job building gRPC C++ for Windows. Note the requirements are Window 7 or later and VS2015 Update 3 or later. Note that you can configure it the way you want it by using a triplet, e.g. .\vcpkg.exe install grpc --triplet x86-windows-sta...
gRPC
39,982,065
27
grpc-java uses an executor in its ServerBuilder, which if not defined by the builder.executor() method, uses a static cached thread pool by default. What is the exact use of this executor? Does it just execute the handler methods or does it do “something else” as well? Also, how does grpc define the netty worker EventL...
The Executor that you provide is what actually executes the callbacks of the rpc. This frees up the EventLoop to continue processing data on the connection. When a new message arrives from the network, it is read on the event loop, and then propagated up the stack to the executor. The executor takes the messages an...
gRPC
42,408,634
27
I am using grpc for message passing and am testing a simple server and client. When my message size goes over the limit, I get this error. grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with (StatusCode.INVALID_ARGUMENT, Received message larger than max (7309898 vs. 4194304))> How do I increase the...
Changing the message_length for both send and receive will do the trick. channel = grpc.insecure_channel( 'localhost:50051', options=[ ('grpc.max_send_message_length', MAX_MESSAGE_LENGTH), ('grpc.max_receive_message_length', MAX_MESSAGE_LENGTH), ], )
gRPC
42,629,047
27
When using gRPC from Java, can I cache stubs (clients) and call them in a multi-threaded environment or are the channels thread-safe and can be safely cached? If there is a network outage, should I recreate the channel or it is smart enough to reconnect? I couldn't find relevant info on http://www.grpc.io/docs/ Thanks
Answer to first question: Channels are thread safe; io.grpc.Channel is marked with @ThreadSafe annotation. Stubs are also thread-safe, which is why reconfiguration creates a new stub. Answer to second question: If there is a network outage, you don't need to recreate the channel. The channel will reconnect with exponen...
gRPC
33,197,669
25
I know we are comparing 2 different technologies, but I would like to know pros and cons of both. WCF is present for almost a decade now. Didn't anything similar exist in java world until now?
At a very high level they would both appear to address the same tooling space. However, the differences I can pick up on: GRPC does not use SOAP to mediate between client and service over http. WCF supports SOAP. GRPC is only concerned with RPC style communication. WCF supports and promotes REST and POX style services...
gRPC
35,694,273
25
I am specifying a number of independent gRPC services that will all be hosted out of the same server process. Each service is defined in its own protobuf file. These are then run through the gRPC tools to give me the target language (c# in my case) in which I can then implement my server and client. Each of those separ...
Protocol buffers solve this problem by using a different package identifier. Each message will be placed in a different Protocol buffer specific package, which is independent of the C# namespace. For example: // common.proto syntax "proto3"; package my.api.common; option csharp_namespace = "My.Api.Common"; message...
gRPC
40,631,796
25
I was going through this code of gRPC server. Can anyone tell me the need for reflection used here Code : func main() { lis, err := net.Listen("tcp", port) if err != nil { log.Fatalf("failed to listen: %v", err) } s := grpc.NewServer() pb.RegisterGreeterServer(s, &server{}) // Register r...
Server reflection is not necessary to run the helloworld example. The helloworld example is also used as a server reflection example, that's why you see the reflection registering code there. More about server reflection: Server reflection is a service defined to provides information about publicly-accessible gRPC serv...
gRPC
41,424,630
25
I have to add a custom header in an android grpc client. I am unable to send it successfully. public class HeaderClientInterceptor implements ClientInterceptor { @Override public < ReqT, RespT > ClientCall < ReqT, RespT > interceptCall(MethodDescriptor < ReqT, RespT > method, CallOptions callOptions, Ch...
The edited version in the question works too.In GRPC there are many ways to add headers (called meta data) . We can add meta data like in my question above using interceptor or we can add meta data for the client stub or you can add it before making request in the client stub channel . // create a custom header Metadat...
gRPC
45,125,601
25
I have a use case where many clients need to keep sending a lot of metrics to the server (almost perpetually). The server needs to store these events, and process them later. I don't expect any kind of response from the server for these events. I'm thinking of using grpc for this. Initially, I thought client-side strea...
the issue is that client side streaming cannot ensure reliable delivery at application level (i.e. if the stream closed in between, how many messages that were sent were actually processed by the server) and I can't afford this This implies you need a response. Even if the response is just an acknowledgement, it is s...
gRPC
56,766,921
25
We need to convert Google Proto buffer time stamp to a normal date. In that circumstance is there any way to convert Google Proto buffer timestamp to a Java LocalDate directly?
tl;dr As a moment in UTC, convert to java.time.Instant. Then apply a time zone to get a ZonedDateTime. Extract the date-only portion as a LocalDate. One-liner: Instant .ofEpochSecond( ts.getSeconds() , ts.getNanos() ) .atZone( ZoneId.of( "America/Montreal" ) ) .toLocalDate() Convert First step is to convert the Ti...
gRPC
52,645,487
24
I want to use gRPC with .NET in an asp.net core web application. How do I generate the necessary .proto file from an existing C# class and model objects? I don't want to re-write a .proto file that mirrors the existing code, I want the .proto file to be auto-generated from the class and model objects. I call this metho...
You can use Marc Gravell’s protobuf-net.Grpc for this. Having a code-first experience when building gRPC services is the exact use case why he started working on it. It builds on top of protobuf-net which already adds serialization capabilities between C# types and protobuf. Check out the documentation to see how to ge...
gRPC
58,768,379
24
When you compile Xcode for Mac app or other iOS, you may see below error Signing for "gRPC-C++-gRPCCertificates-Cpp" requires a development team. Select a development team in the Signing & Capabilities editor. My Xcode version: 11.2.1 Mac OS: 10.15.1
It is easy to fix, follow my steps: In Xcode, Choose Pods on your left Go to Signing & Capabilities, choose gRPC-C++-gRPCCertificates-Cpp Choose Team Restart Xcode or clean Xcode with short cut: Command + Shift + k
gRPC
59,062,663
24
I read the gRPC Core concepts, architecture and lifecycle, but it doesn't go into the depth I like to see. There is the RPC call, gRPC channel, gRPC connection (not described in the article) and HTTP/2 connection (not described in the article). I'm interested in knowing how these come together. For example, what happen...
The connection is not a gRPC concept. It is not part of the normal API and is an implementation detail. This should be seen as fairly normal, like HTTP libraries providing details about HTTP exchanges but not exposing connections. It is best to view RPCs and connections as two mostly-separate systems. The only real gua...
gRPC
63,749,113
24
Upon discovering gRPC, I stumbled across this blog post Why isn’t everyone already using gRPC in their SPAs? Traditionally it’s not been possible to use gRPC from browser-based applications, because gRPC requires HTTP/2, and browsers don’t expose any APIs that let JS/WASM code control HTTP/2 requests directly. But the...
I have used grpc in my projects and understand your questions about it. The first two questions can be answered via a quote from grpc.io followed by some elaboration. - For me, another question that still remains why HTTP2 is not supported through browser APIs, to which I cannot find any documentation on. - It looks li...
gRPC
65,823,598
24
I don't like tools that do many things at once. So GRPC seems to me overhead, it's like kubernetes. GRPC is the tool that combines actually two things: extended Protobuf (Service support) and HTTP2. I read a lot of articles saying that using GRPC is awesome for performance. And there are two reasons protobuf is used,...
As you pointed out, gRPC and Protobuf are often conflated. While, in the vast majority of cases, gRPC will be using protobuf as an IDL and HTTP/2 as the transport, this is not always the case. So then, what value does gRPC provide on its own? For starters, it provides battle-tested implementations of each of those tran...
gRPC
58,767,467
23
I'm using gRPC with Python as client/server inside kubernetes pods... I would like to be able to launch multiple pods of the same type (gRPC servers) and let the client connect to them (randomly). I dispatched 10 pods of the server and setup a 'service' to target them. Then, in the client, I connected to the DNS name o...
Let me take the opportunity to answer by describing how things are supposed to work. The way client-side LB works in the gRPC C core (the foundation for all but the Java and Go flavors or gRPC) is as follows (the authoritative doc can be found here): Client-side LB is kept simple and "dumb" on purpose. The way we've ch...
gRPC
39,643,841
22
I'm using grpc golang to communicate between client and server application. Below is the code for protoc buffer. syntax = "proto3"; package Trail; service TrailFunc { rpc HelloWorld (Request) returns (Reply) {} } // The request message containing the user's name. message Request { map<string,string> inputVar = 1;...
proto3 has type Any import "google/protobuf/any.proto"; message ErrorStatus { string message = 1; repeated google.protobuf.Any details = 2; } but if you look at its implementation, it is simply as message Any { string type_url = 1; bytes value = 2; } You have to define such a message yourself by possibly usi...
gRPC
40,259,551
22
Given the following gRPC server side code: import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" .... ) .... func (s *Router) Assign(ctx context.Context, req *api.Request(*api.Response, error) { return nil, status.Errorf(codes.PermissionDenied, } .... What is the recommended techn...
Let's say your server returns codes.PermissionDenined like this ... return nil, status.Error(codes.PermissionDenied, "PERMISSION_DENIED_TEXT") If your client is Golang as well can also use the status library function FromError to parse the error. I use a switch to determine the error code returned like so // client ...
gRPC
52,969,205
22
I'm using grpc with protobuf lite in android implementation. but protobuf lite doesn't have google time stamp, and my protos has import "google/protobuf/timestamp.proto". so i added implementation 'com.google.protobuf:protobuf-java:3.7.1' to gradle that contains google time stamp. but after that code compilaition has ...
The missing classes is a known issue. Full proto and lite proto can't be mixed; they use different generated code. Do not depend on protobuf-java as an implementation dependency, but as a protobuf dependency which will cause gradle-protobuf-plugin to generate code for the .protos. dependencies { ... protobuf 'com.g...
gRPC
57,019,439
22
From the introduction on gRPC: In gRPC a client application can directly call methods on a server application on a different machine as if it was a local object, making it easier for you to create distributed applications and services. As in many RPC systems, gRPC is based around the idea of defining a service, specif...
No, a server cannot invoke calls on the client. gRPC works with HTTP, and HTTP has not had such semantics in the past. There has been discussion as to various ways to achieve such a feature, but I'm unaware of any work having started or general agreement on a design. gRPC does support bidirectional streaming, which may...
gRPC
30,008,476
21
I have a gRPC server that hosts two asynchronous services ("Master" and "Worker"), and I would like to implement graceful shutdown for the server. Each service has its own grpc::CompletionQueue. There appear to be two Shutdown() methods that might be relevant: grpc::CompletionQueue::Shutdown() and grpc::Server::Shutdow...
TL;DR: You must call both grpc::Server::Shutdown() and grpc::CompletionQueue::Shutdown() (for each completion queue used in the service) to shut down cleanly. If you call cq_->Shutdown(), the only observable effect is that subsequent calls to Service::AsyncService::RequestFoo() (the generated method for the correspond...
gRPC
35,708,348
21
I'd like to know how to add metadata to a nodejs grpc function call. I can use channel credentials when making the client with var client = new proto.Document('some.address:8000', grpc.credentials.createInsecure() ) Which are send when using client.Send(doc, callback), but the go grpc server looks in the call meta...
You can pass metadata directly as an optional argument to a method call. So, for example, you could do this: var meta = new grpc.Metadata(); meta.add('key', 'value'); client.send(doc, meta, callback);
gRPC
37,526,077
21
I am having trouble finding the source of this error. I implemented a simple service using protobuf: syntax = "proto3"; package tourism; service RemoteService { rpc Login(LoginUserDTO) returns (Response) {} } message AgencyDTO{ int32 id=1; string name=2; string email=3; string password=4; } message LoginU...
For me it was that I forget adding endpoint of gRpc service in startup class. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseEndpoints(endpoints...
gRPC
44,102,096
21
I have been studying about Apache Thrift, ProtoBuf and Flatbuffers. I found the tutorial to use gRPC with protobuf at link but I am not finding any documentation to use gRPC with Flatbuffers. Can some one point me to the relevant documentation? I checked it on Google as well as on Stackoverflow. Any help would be appre...
Since this question was first asked, progress has been made in a) making GRPC codegen independent of protobuf (see https://github.com/grpc/grpc/pull/6130) and then to integrate that codegenerator in the flatbuffers compiler flatc: https://github.com/google/flatbuffers/commit/48f37f9e0a04f2b60046dda7fef20a8b0ebc1a70 Thi...
gRPC
34,170,945
20
gRPC is a "general RPC framework" which uses ProtoBuffer to serialize and deserialize while the net/rpc package seems could do "nearly" the same thing with encoding/gob and both are under the umbrella of Google. So what's the difference between them? What pros and cons dose choosing one of them have?
Well, you have said it yourself. gRPC is a framework that uses RPC to communicate. RPC is not Protobuf but instead Protobuf can use RPC and gRPC is actually Protobuf over RPC. You don't need to use Protobuf to create RPC services within your app. This is a good idea if you are doing libraries/apps from small to medium ...
gRPC
39,034,114
20
I'm occasionally getting cancellation errors when calling gRPC methods. Here's my client-side code (Using grpc-java 1.22.0 library): public class MyClient { private static final Logger logger = LoggerFactory.getLogger(MyClient.class); private ManagedChannel channel; private FooGrpc.FooStub fooStub; pr...
grpc-java supports automatic deadline and cancellation propagation. When an inbound RPC causes outbound RPCs, those outbound RPCs inherit the inbound RPC's deadline. Also, if the inbound RPC is cancelled the outbound RPCs will be cancelled. This is implemented via io.grpc.Context. If you do an outbound RPC that you wan...
gRPC
57,110,811
20
Using aspnetcore 3.1 and the Grpc.AspNetCore nuget package, I have managed to get gRPC services running successfully alongside standard asp.net controllers as described in this tutorial. However I would like to bind the gRPC services to a specific port (e.g. 5001), preferably through configuration instead of code if po...
In the ASP.NET Core 6.0 ports can be changed in the Properties > launchSettings.json file. But this file is considered only if you run the server from the Visual Studio or VS Code. I was trying to run the server directly using the .exe file for testing. The server was running with the default ports: "http://localhost:5...
gRPC
63,827,667
20
New to gRPC and couldn't really find any example on how to enable SSL on the server side. I generated a key pair using openssl but it complains that the private key is invalid. D0608 16:18:31.390303 Grpc.Core.Internal.UnmanagedLibrary Attempting to load native library "...\grpc_csharp_ext.dll" D0608 16:18:31.424331 Gr...
Here's what I did. Using OpenSSL, generate certificates with the following: @echo off set OPENSSL_CONF=c:\OpenSSL-Win64\bin\openssl.cfg echo Generate CA key: openssl genrsa -passout pass:1111 -des3 -out ca.key 4096 echo Generate CA certificate: openssl req -passin pass:1111 -new -x509 -days 365 -key ca.key -out ca...
gRPC
37,714,558
19
I have created a very simple program which should list the topics available in a Google Cloud project. The code is trivial: using System; using Google.Pubsub.V1; public class Test { static void Main() { var projectId = "(fill in project ID here...)"; var projectName = PublisherClient.FormatProj...
This is currently a limitation in gRPC 0.15, which Google.Pubsub.V1 uses as its RPC transport. Under msbuild, the build/net45/Grpc.Core.targets file in the Grpc.Core package copies all the native binaries into place. Under DNX, the packages weren't copied and gRPC tries to look for the file in the right place with the ...
gRPC
38,349,230
19
Does anyone know where I can find an example of a gRPC protobuf file that imports from a different file and uses a protobuf message in a return? I can't find any at all. I have a file... syntax = "proto3"; package a1; import "a.proto"; service mainservice { rpc DoSomething(...) returns (a.SomeResponse) {} } a.prot...
Found the answer... need to make sure the package name of a.proto is used when specifying the object imported (eg: a_package_name.SomeResponse). Example: base.proto syntax = "proto3"; option csharp_namespace = "Api.Protos"; package base; message BaseResponse { bool IsSuccess = 1; string Message = 2; } user.pro...
gRPC
41,150,779
19
I am trying to use Google Cloud Endpoints to make a gRPC based api that can transcode incoming REST requests. I am following their example code but I can not any documentation on how to properly import and compile with the annotation.proto or the empty.proto. Thank you!
I didn't understand that this was part of grpc-gateway. By following the docs I ran protoc -I/usr/local/include -I. -I$GOPATH/src -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --go_out=plugins=grpc:. *.proto and compiled successfully.
gRPC
43,313,186
19
I am trying to transfer large amounts of structured data from Java to Python. That includes many objects that are related to each other in some form or another. When I receive them in my Python code, it's quiet ugly to work with the types that are provided by protobuf. My VIM IDE crashed when trying to use autocomplete...
If you are using a recent Python (3.7+) then https://github.com/danielgtaylor/python-betterproto (disclaimer: I'm the author) will generate very clean Python dataclasses as output which will give you proper typing and IDE completion support. For example, this input: syntax = "proto3"; package hello; // Greeting repre...
gRPC
49,755,565
19
I want to mock my grpc client to ensure that it is resilient to failure by throwing an new StatusRuntimeException(Status.UNAVAILABLE) (This is the exception that is thrown when java.net.ConnectException: Connection refused is thrown to the grpc client). However, the generated class is final, so mock will not work. How ...
Do not mock the client stub, or any other final class/method. The gRPC team may go out of their way to break your usage of such mocks, as they are extremely brittle and can produce "impossible" results. Mock the service, not the client stub. When combined with the in-process transport it produces fast, reliable tests. ...
gRPC
59,536,673
19
Following the docs on how to set up a gRPC gateway, I find myself stuck at step four of generating the grpc gateway. Namely, things fall apart when the following line is added: import "google/api/annotations.proto"; The documentation says You will need to provide the required third party protobuf files to the protoc c...
I solved it one way by adding third party google apis and its content to the root of my project. Feels wrong, but apparently this is encouraged
gRPC
66,168,350
19
I've seen two different ways of declaring an gRPC service using Protobuf v3. Some code has the rpc line end with a semicolon (such as the current proto3 documentation): service SearchService { rpc Search (SearchRequest) returns (SearchResponse); } Other code has the rpc line end with {}: service Greeter { rpc SayH...
Nothing, really; they are equivalent. The {} syntax is used when there are options. If you don't specify any options, either syntax works (just like in C!).
gRPC
30,106,667
18