GithubHelp home page GithubHelp logo

isabella232 / stream_consumer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from adobe-research/stream_consumer

0.0 0.0 0.0 188 KB

Multi-threaded HTTP stream consumer, with asynchronous spooling and multi-threaded production

License: Apache License 2.0

Ruby 100.00%

stream_consumer's Introduction

StreamConsumer

Multi-threaded HTTP stream consumer, with asynchronous spooling and multi-threaded production. Includes an SDK for producers and statistics, including an implemention of a Kafka topic producer and a MySQL statistics updater.

Ruby Version

JRuby jruby-1.7.12 using ruby 2.0 compatibility mode. Install via rvm: https://rvm.io/

Dependencies

Uses http_streaming_client.

See stream_consumer.gemspec for specific details.

Installation

Add this line to your application's Gemfile:

gem 'stream_consumer'

And then execute:

$ bundle install

Or install it directly via gem with:

$ gem install stream_consumer

Simple Example

require 'stream_consumer'

updater = StreamConsumer::Updater::ConsoleStatsUpdater.new
producer = StreamConsumer::Producer::ConsoleDataProducer.new

def calculate_lag
  # code to determine the lag for a message, called once per block of messages
end

options = { stats_updater: updater, data_producer: producer, options_factory: HttpStreamingClientOptions.new }
consumer = StreamConsumer::Consumer.new(config.merge(options))
consumer.run { |line,now| calculate_lag(line, now) }

Take a look at the test cases for more significant examples including the use of configuration options, signal handling, interrupts/shutdown handling, stream signal prefix recognition, and the lag calculation function.

Configuration Options

See config/stream_consumer.conf.sample for a sample configuration listing all options.

Logging

The gem supports configurable logging to both STDOUT and a log file.

To configure gem logging to STDOUT, specify the following in your code:

StreamConsumer.logger.console = true

To configure gem logging to a log file named "test.log", specify the following in your code:

StreamConsumer.logger.logfile = "test.log"

To set the log level, specify the following in your code (e.g. to set the log level to :debug):

StreamConsumer.logger.level = Logger::DEBUG

To set a custom log tag for logging, specify the following in your code:

StreamConsumer.logger.tag = "your_custom_tag"

Or use your own logger instead:

StreamConsumer.logger = <your Logger::logger instance>

Unit Test Coverage

Unit test suite implemented with rspec. Run via:

$ rake

or:

$ rspec

Individual test suites in the spec directory can be run via:

$ rspec spec/<spec filename>.spec

An HTML coverage report is generated at the end of a full test run in the coverage directory.

Fixed Issues

See CHANGELOG

License

Licensed under the Apache Software License 2.0. See LICENSE file.

stream_consumer's People

Contributors

davidtompkins 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.