Skip to content

Latest commit

 

History

History

ex

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

  • Written in pure Elixir
  • Zero dependencies

Installation

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

def deps do
  [
    {:pika, "~> 0.1"}
  ]
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"}