Comments (4)
It actually doesn't look like const values are generating any code at all?
from elixir-thrift.
I have a POC solution for this. The approach I took was, given a file "foo.thrift" with a non-empty set of constants, generate a module called FooConstants
that defines a function for each constant that returns the value of the constant. Is this a reasonable approach? A couple alternatives I thought of:
- Generate
Foo.Constants
instead ofFooConstants
(FooConstants
seems consistent with the way other thrift libs work and we don't nest any other modules aside from namespacing) - Generate macros instead of functions (this could get hairy with quotes/unquotes and compilation order?)
from elixir-thrift.
It definitely should generate something for constants -- only reason it doesn't is that we hadn't gotten to it.
Naming it is tricky. Using the filename as you suggested, foo.thrift and subdir/foo.thrift would both generate a FooConstants module. Using the namespace, same thing, multiple thrift files can contain the same namespace. I think I favor generating a module based on the namespace though because we have more control over it. We have a bunch of thrift files that we can't easily move around or rename, but all these other systems depend on them and they include each other, but we can add elixir
namespaces to them to control what gets generated.
I know you have the separate issue with Apache raising errors about unrecognized namespaces. We need to fix that somehow.
Regarding macros vs functions, I liked macros for enums because they're so often used for matching. For constants, maybe it doesn't make as much difference. You can always put the function call in a variable or module attribute or unquote if you really need to match it, but it seems like it would happen less often. What do you all think?
from elixir-thrift.
I'm seeing some of the issues that @pguillory mentions in the previous comment with the current approach to generating constants.
Start with a file named userservice.thrift
that includes some constants and a service UserService
definition. The generator will produce a file named userservice.ex
(defmodule Userservice
) containing the constants and a file named user_service.ex
(defmodule UserService
) containing the service definition.
I'm not quite sure what should change, but it's a bit confusing, and I suppose we could run into problems on case-insensitive file systems.
I suppose we could look at merging the constants into user_service.ex
(defmodule UserService
) because it's the most similar name. But that's more of a coincidence with the service name matching the name of the .thrift
file.
from elixir-thrift.
Related Issues (20)
- Split generated serde code from transport handling by introducing middlewares HOT 12
- IntegrationTest test failures
- Adopt the Mix.Task.Compiler behaviour
- ssl:ssl_accept/3: deprecated; use ssl:handshake/3 instead HOT 1
- Add support for a header based protocol
- Service tests fail to start child
- A typedef which references an included typedef fails to compile
- "Client exit" service test sometimes fails HOT 2
- Represent AST names using a list of atoms
- Spawn a process for each client request
- Debugging oneway calls HOT 3
- Support schema annotations to opt-in to copy strings out of the binary HOT 7
- Multiplexing Support HOT 1
- Difference with pinterest/riffed HOT 1
- Error: expected -> clauses for :rescue in "try" HOT 2
- RFC: Middleware framework HOT 1
- Buffered transport for binary protocol HOT 2
- Sharing modules across apps HOT 4
- Recommended way to handle server downtime HOT 5
- Make thrift parser a separate package HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elixir-thrift.