pika

Elixir implementation of Pika

Combine Stripe IDs with Snowflakes you get Pika! The last ID system you'll ever need! Combining pragmatism with functionality

Features

Installation

The package can be installed by adding pika to your list of dependencies in mix.exs:

def deps do
  [
    {:pika, "~> 0.3"}
  ]
end

In your config.exs:

config :pika,
  prefixes: [
    %{prefix: "user", description: "User IDs"},
    %{prefix: "server", description: "Server IDs", secure: true},
    # ...
  ]

Example

Pika.Snowflake should be started under a Supervisor or Application before you start using Pika.gen/1 or Pika.deconstruct/1

defmodule MyApp.Application do
  use Application

  def start(_type, _args) do
    children = [Pika.Snowflake]

    Supervisor.start_link(children, strategy: :one_for_one)
  end
end

Somewhere in your application:

# ...
Pika.gen("user") # or Pika.gen!("user")

{:ok, "user_MjgyNDQ2NjY1OTk3MjEzNjk3"}

License

The code in this repository is licensed under the Apache-2.0 license, you can find a copy in the local tree.