vegabook

vegabook

How to use Google.Protobuf.Timestamp with elixir-grpc

I’m using elixir-grpc to write a client for my Bloomberg API gRPC implementation. This is working quite well in Python, and I now want to bring the Bloomberg API to Elixir. Naturally timestamps are going to be necessary, but I don’t know how to use them in Elixir.

Elixir-grpc says it uses the protobuf library which in turn says that “since :protobuf version 0.14.0 we include all of the well known Google Protobuf modules” (which is strange since their latest release is 0.13.0).

Anyway I’m getting errors with Google.Protobuf.Timestamp. Here is my proto file that uses timestamps, and this successfully compiles to elixir code using protoc --elixir_out=plugins=grpc:../lib *.proto. You can see the output here, but when I try to do a simple ping/pong to the server, there’s a massive error which mentions that Google.Protobuf.Timestamp is not available:

So in Python I would bring Google.Protobuf.Timestamp (and Struct and Empty) in like this:

from google.protobuf.struct_pb2 import Struct
from google.protobuf.timestamp_pb2 import Timestamp as protoTimestamp
from google.protobuf import empty_pb2

and then I could use them, but I don’t know how to do this in Elixir. Should I be generating my own code from the canonical Google.Protobuf.Timestamp proto files? This seems strange as I would think either elixir-grpc or protobuf would have done that already.

Marked As Solved

Also Liked

vegabook

vegabook

fabulous!

I’ll let grpc-elixir maintainers that this should be in their docs.

Goodbye python, java, c++, behold Bloomberg API data, now in Elixir:

Where Next?

Popular in Questions Top

Tee
can someone please explain to me how Enum.reduce works with maps
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
makeitrein
Hey all, just started picking up Elixir last week and am writing a scraper as a learning project. Baby step #1 is extracting the number ...
New
qwerescape
Is there a way to get the call stack or stack trace at any point in the code? Not from exceptions, but an expression that returns how the...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New

We're in Beta

About us Mission Statement