Cart Manager for Ecommerce Websites
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config
images
lib
test
.gitignore
.travis.yml
LICENSE
README.md
mix.exs
mix.lock

README.md

Build Status Coverage Status

Cart

Create, manage baskets

Supervisor tree

Supervision tree of Cart Manager

Usage

Create new basket using user_id

basket_id = Basket.Manager.create_basket_or_return_basket_id(Basket.Manager, user_id)

With basket_id created we can get the basket pid

basket_pid = Basket.Manager.get_basket(Basket.Manager, basket_id)

With basket_pid we can add_product, delete_product, purchase through Basket(Agent) functions

 Basket.add_product(basket_pid, product_id)
 Basket.delete_product(basket_pid, product_id)
 Basket.purchase(basket_pid)

Benchmark Script

start = :os.system_time(:seconds)
stream = 1..200_000 |> Stream.each(fn(number) ->
    with [head | tail] <- Integer.digits(number),
        list <- Enum.drop_while(tail, &(&1 == 0)),
        false <- (length(list) > 0),
        seconds <- :os.system_time(:seconds) - start,
        do: IO.puts "#{number} done in #{seconds} seconds"
        
        
    basket_id = Basket.Manager.create_basket_or_return_basket_id(Basket.Manager, number)
    basket_pid = Basket.Manager.get_basket(Basket.Manager, basket_id)
    Basket.add_product(basket_pid, number)
end)
Stream.run(stream)