Coder Social home page Coder Social logo

shorturl's Introduction

shorturl

An OTP application for url shortening, developed in erlang and riak-kv as datastore.

Pre-requisites

  • riak docker setup commands
    • Load and run riak-kv docker image
    docker run --name=riak -d -p 8087:8087 -p 8098:8098 basho/riak-kv
    
    • Login to riak container console for issuing admin commands.
    bash -c "clear && docker exec -it riak sh"
    
    • Create and activate CRDT bucket type
    #>riak-admin bucket-type create crdt_counter_type '{"props":{"datatype":"counter"}}'
    #>riak-admin bucket-type activate crdt_counter_type
    

Build

$ sh pre_compile.sh

$ rebar3 compile

Eunit

$ rebar3 eunit

Expected Compilation Issue/s (Even after executing pre_compile.sh)

Compiling _build/default/lib/riakc/src/riakc_pb_socket.erl failed _build/default/lib/riakc/src/riakc_pb_socket.erl:2384: call to crypto:rand_bytes/1 will fail, since it was removed in 20.0; use crypto:strong_rand_bytes/1

Fix

open rebar.config of riakc

vi _build/default/lib/riakc/rebar.config

change two lines as per 'riakc_erl20.diff' file

diff --git a/rebar.config b/rebar.config index 5fb1e7f..5c6394f 100644 --- a/rebar.config +++ b/rebar.config @@ -1,4 +1,4 @@ -{require_otp_vsn, "R15|R16|17|18|19"}. +{require_otp_vsn, "R15|R16|17|18|19|20"}.

{cover_enabled, true}.

@@ -9,7 +9,7 @@ warnings_as_errors, {platform_define, "^[0-9]+", namespaced_types}, {platform_define, "(?=^[0-9]+)(?!^17)", deprecated_now},

  • {platform_define, "^19", deprecated_19}
  • {platform_define, "^(19|20)", deprecated_19} ]}.

Starting the Application

In shell mode

$ rebar3 shell

Test Curl Commands

curl -X POST -d 'www.google.com'  http://localhost:8080/shorturl/generate_token

Output Token -> ChN7N1zDAA==

curl -X GET -d 'ChN7N1zDAA=='  http://localhost:8080/shorturl/redirect

Output URL -> www.google.com

shorturl's People

Contributors

shhnwz avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.