wjanssens/flexid-elixir

Need for more detailed usage guide

Closed this issue · 4 comments

I really want to commend the great work done with this package however it seems there is no detailed guide on how it can be used especially with phoenix framework. I've gone through the documentation but it doesn't seem helpful enough.

I've only just started using it myself. Here's what I've done. I'll add some better documentation when I get a chance.

in application.ex
supervisor(FlexId, [946_684_800_000, 6, 6, 4, [name: :id_generator]])

def insert(username) do
    shard = FlexId.make_partition(username)
    id = FlexId.generate(:id_generator, shard)

    %Subject{
      id: id
    }
    |> Repo.insert()
  end
  def insert(subject_id, ........) do
    shard = FlexId.extract_partition(:id_generator, subject_id)
    id = FlexId.generate(:id_generator, shard)

   .......

Thanks immensely for your prompt response.

You can also checkout the documentation here: https://hexdocs.pm/flexid/FlexId.html

But I agree that it's not concise enough to know how to get started quickly.

A work in progress Phoenix/Ecto application that is using this is here: https://github.com/wjanssens/votr