victorbjorklund

victorbjorklund

Specify which parts of library to compile or not

I’m going to try to build a library (that I can hopefully publish) that allows access to statistics reports from the Swedish Statistics Authority. Basically they have a bunch of statistics data but the issue is they use very weird API:s for accessing them so I wanna provide a more easy way to get the data by wrapping the api:s in a nice library.

However they have a lot of reports and data so I will probably have to write a module per report. And it seems a bit wasteful to include all (I’m not sure how many reports in total they got but wouldn’t be surprised if it is over 500) for a project that just wanna access how the population size of each municipality.

I get that it might be hard/impossible to “tree-shake” since code can be called dynamically at runtime but can I provide a way to for example specify in the config which reports they want to actually use? Something like this:

config :scb_ex,
  reports: [:municipality_population]

Most Liked

al2o3cr

al2o3cr

There was just a post on the Dashbit blog arguing for smaller SDK surfaces:

Are the many reports different enough to need different code?

arcyfelix

arcyfelix

I guess you could hack it by slightly changing your approach.
Instead of a single mix project, you can have a single umbrella project and your modules will become small libraries.
You can control what has access to what with Boundary — boundary v0.10.3 to provide a meaningful error when one “module/report” depends on another that is not compiled (strongly advised against it).
Or you can extract these common pieces to the Core which is exposed to all Reports.

Where Next?

Popular in Questions Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
Phillipp
Hey, I have a NanoPi-M3 and try to install Elixir on their Ubuntu image. I followed the Raspberry Pi installation instructions from the ...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
sabri
Can someone explain the settings of pool_size of Ecto in config file? and what is the recommend size? Thanks
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

Other popular topics Top

chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 30048 115
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
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
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
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
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New

We're in Beta

About us Mission Statement