Giter Club home page Giter Club logo

floki's Introduction

Floki

Build Status Coverage Status

Although it works fairly well please do not trust it for any kind of production data

Floki borrows concepts from both Kafka and Amazon SQS into an easy to use package. Queues have independent channels which allow efficient fanout and are persisted to disk. Clients talk to it using Redis protocol and commands, so all Redis existing clients can be used. Although there's no replication or clustering support and it might never have.

The design is based on a single thread to handle all networking using an async io but the actual commands are dispatched to a thread pool for execution. State is kept in-memory and checkpointed to disk periodically, queue storage is based on a Write Ahead Log splited into segments.

I started this project in order to evaluate Rust capabilities in a real world project which I thought it could shine and once you get used to the rust way it indeed does.

Goals

  • Redis protocol
  • Multiple Queues
  • Multiple Channels per Queue (for efficient fanout)
  • Disk Backed
  • Runs on most Unix systems
  • Crash resistant
  • Soft and Hard retention periods
  • Soft and Hard retention sizes
  • Channel seek, with either ID or timestamp

TODO

  • Ticket based Acknowledgement
  • Map Floki commands to Redis commands in a sensible way
  • Better error handling
  • Lots of documentation
  • Opt-in persistency guarantee (needs group commit-ish implementation)
  • Make internal data structures size-bounded, based on configurations

Floki Protocol (Redis)

How Floki maps Redis commands. This is a work in progress and constantly changing.

RPUSH push one or more messages

RPUSH queue_name message1 [message2, ...]

Returns the number of messages inserted

HMGET get one or more messages

HMGET queue_name channel_name number_or_messages [long_pooling_timeout]

Returns an array with three items for each message. The first would be the id, the second is the ticket (for acknowledging, see bellow) and the third would be the message itself. Note: Floki will return as soon as there's one message available

HMSET seeks the channel

HMGET queue_name channel_name TS|ID seek_timestamp|seek_id

Seeks the specified channel to the specified id or timestamp.

Note: Floki won't error if the id or timestamp is either in the future or is already gone from the underlying storage. If it's set to a non-existent past, gets will just return the first available message.

HDEL ack messages

HDEL queue_name channel_name ticket1 [ticket2, ...]

Acknowledge messages using their tickets. Returns the number of successful acknowledges.

SET create queue/channel

SET queue_name channel_name [NX]

SETNX queue_name channel_name

Creates the specified queue and channel, will error if the queue or channel already exists unless the nx flag or the setnx commands is used.

DEL delete queue/channel

DEL queue_name [channel_name]

Deletes a channel, if specified, otherwise deletes the queue.

SREM purge queue/channel

SREM queue_name channel_name_or_*

Note: you can also use * as the channel name to purge all channels, effectively purging the entire queue and allowing all used disk space to be reclaimed.

INFO get information

INFO [server|queues|queues.queue_prefix]

All variants return an array with a single json encoded object.

server return information about the server

queues return information about all queues

queues.queue_prefix return information about all queues matching the given prefix

CONFIG GET get configuration

CONFIG GET [server|queues.queue_name]

All variants return an array with a single json encoded object.

server return the server configuration

queues.queue_name return the specified queue configuration

CONFIG SET set configuration

CONFIG SET [server|queues.queue_name].config_name config_value

Like the previous but to change configuration values.

config_name and config_value accept the same format as their corresponding entry in the floki.toml file, check it's contents for documentation about which values can be changed at runtime.

Example

See example helloworld.rs

Configuration

See the configuration file floki.toml

Running

You'll need a recent version of rust nightly and cargo installed.

On the root of the repostory type:

RUST_BACKTRACE=1 RUST_LOG=floki=info cargo run --release

You can also cargo install it using cargo install --path . then RUST_BACKTRACE=1 RUST_LOG=floki=info floki

Copyright and License

Code released under the MIT license.

floki's People

Contributors

arthurprs avatar danburkert avatar seanjensengrey avatar

Watchers

 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.