Skip to content
/ alaska Public

A distributed processing system built on top of Malamute's messaging model.

Notifications You must be signed in to change notification settings

mfornos/alaska

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alaska

Alaska Workers is a distributed processing system built on top of Malamute's messaging model.

This model provides:

  • Multiple messaging patterns
    • On-demand streams
    • Mailboxes
    • Service request distribution
  • Advanced pattern matching
  • Load balancing
  • Reliable delivery

Status

The Technology Readiness Level of this project is experimental proof of concept.

Dependencies

  1. CMake
  2. Malamute
  3. Lua
  4. LuaRocks

Optionally, you may also want to install LuaJIT.

Building from Source

Just run ./build.sh. If everything goes well you'll find the executable files in the 'bin/' folder.

Running

  1. First of all, make sure that an instance of Malamute is running. If not, start one:
$> malamute
Malamute service/0.2.0
Copyright (c) 2014-15 the Contributors
This Software is provided under the MPLv2 License on an "as is" basis,
without warranty of any kind, either expressed, implied, or statutory.

I: 16-01-03 19:41:27 loading configuration from 'malamute.cfg'...
N: 16-01-03 19:41:27 server is using NULL security
  1. Now you can run your worker processes:
$> ./alaska
Alaska Workers/0.0.1 (POC)
Copyright (c) 2016 the Contributors
This Software is provided under the MPLv2 License on an "as is" basis,
without warranty of any kind, either expressed, implied, or statutory.

I: 16-01-03 18:06:19 Loading configuration from 'alaska.cfg'
I: 16-01-03 18:06:19 Connected (AW::wildhorse.local::9352-BE39)
I: 16-01-03 18:06:19 Alaska worker ready (pool:4)

Note that, by default, the worker is subscribed to the service name 'default' and receives requests addressed to any subject. However, this subject string should match a the file name (without the extension) of a Lua script located in the scripts folder of the worker. Please, take a look at the default configuration file:

worker
    background = "0"
    workdir = "."
    verbose = "0"
    syslog = "0"
    scripts
        dir = "../services"
    pool
        size = "4"
    broker
        endpoint = "tcp://127.0.0.1:9999"
        timeout = "1000"
    service
        address = "default"
        filter = ".*"
    errors
        notify = "1"
        mailbox = "awerr"
  1. Now, you can send some service requests using the Alas Producer:
$> for run in {1..5}; do echo "{\"c\":${run}}" | ./alas; done
Service RQ
-Endpoint: tcp://127.0.0.1:9999
-Address: default
-Subject: dump
-Content:
{"c":1}
...

If no parameter is specified, the service request will be sent for a service named 'default' and with 'dump' as subject value. So, this request will trigger the execution of the 'dump.lua' script in the worker side.

This is the content of the 'dump.lua' file located at the scripts directory of the worker:

-----------------------------------------------------
-- Dump Service
-----------------------------------------------------
-- Parses a JSON representation of the Alaska context global
-- variable and dumps the resulting table using Penlight
-----------------------------------------------------

local s = string.rep('-', 80)
print(s..'\nContext dump from Lua:')

local ctx = require 'cjson'.decode(alaskaContext)
require 'pl.pretty'.dump(ctx)

print(s)

Tips & Tricks

  • The 'worker.scripts.dir' configuration key, defined in 'alaska.cfg', is relative to the directory where alaska is executed.
  • The 'worker.workdir' configuration key is only active when running in background, i.e. as a daemon.

About

A distributed processing system built on top of Malamute's messaging model.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published