- Run tarantool in docker
docker run --name mytarantool -d -p 3301:3301 \
tarantool/tarantool:2.6.0
if run on ARM - then use version 2.10.0-beta1
- Enter in container with docker exec
- Create schemas:
s = box.schema.space.create('short')
s:format({
{name = 'shorted', type = 'string'},
{name = 'original', type = 'string'},
{name = 'created_by', type = 'string'}
})
s:create_index('primary', {
type = 'hash',
parts = {'shorted'}
})
t = box.schema.space.create('transitions')
t:format({
{name = 'id', type = 'string'},
{name = 'shorted', type = 'string'},
{name = 'ip', type = 'string'},
{name = 'ua', type = 'string'}
})
t:create_index('primary', {
type = 'hash',
parts = {'id'}
})
- Create index
t:create_index('shorted_idx', { type = 'tree', unique = false, parts = {'shorted'} })
- Run with command:
go run cmd/shorter/main.go
Server is now running on port 8182
Send http requests below to deployed version of service at address:
http://37.139.34.190/
- Set endpoint
/set?url=http://vk.com/ac
- Get endpoint
/{hash_from_previous_request}
Analytics is available from web UI after creating first short link