Megaphone::Client

Build Status Gem Version

Send events to Megaphone.

Getting Started

Add the gem to your Gemfile:

# Gemfile

gem 'megaphone-client', '~> 1.0' # see semver.org

Usage

In order to be as unobstrusive as possible, this client will append events to local files (e.g. ./work-updates.stream) unless:

  • the MEGAPHONE_FLUENT_HOST and MEGAPHONE_FLUENT_PORT environment variables are set.
  • or the Fluentd host and port values are passed as arguments to the client's constructor

That behaviour ensures that unless you want to send events to the Megaphone streams, you do not need to start Fluentd at all.

Publishing events

  1. Start Fluentd, the easiest way to do so is using a redbubble/megaphone-fluentd container

  2. Create your event and publish it:

# Configure a Megaphone client for your awesome service
client = Megaphone::Client.new({
  origin: 'my-awesome-service',
  host: 'localhost',
  port: '24224'
})

# Create an event
topic = 'work-updates'
subtopic = 'work-metadata-updated'
schema = 'https://github.com/redbubble/megaphone-event-type-registry/blob/master/streams/work-updates-schema-1.0.0.json'
partition_key = '1357924680' # the Work ID in this case
payload = { url: 'https://www.redbubble.com/people/wytrab8/works/26039653-toadally-rad' }

# Publish your event
client.publish!(topic, subtopic, schema, partition_key, payload)

Credits

Megaphone::Client is maintained and funded by Redbubble.

License

Megaphone::Client
Copyright (C) 2017 Redbubble

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.