This seems like a good case for GenStage
.
You could create a producer
that queries your table using a LIMIT
and passes those records on to the consumer
which makes the call to the Google Gmail API.
The only change this would require is your add limit
to your table query:
def get(limit) do
Repo.all(
from t in MyTable,
limit: ^limit,
select: t
)
end
Check out this video for a simple application of the concept.