megaphone-client 0.3.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c576c3f15678249216b1f429627540da6a460a7
4
- data.tar.gz: 30d95da0710f722658bc57e1577b0134bbf3c546
3
+ metadata.gz: ea3788fe007c5771e476cbc5adfde59a540f4f43
4
+ data.tar.gz: c3e00fbf0225d7c439684c84da295af81f5ab51e
5
5
  SHA512:
6
- metadata.gz: 503ccc117d9a16f0717db386ef47a02ab51fd44eaaca158d4f5d8cf7929c64926d715a07e4fb0562898d088d6178f1ed9452c5aba7059f70d435c8890e8dd5c2
7
- data.tar.gz: 786ad699334f6222eb70a9efd1bf1fb350683812a07121d1ffc75286cd44ff72c496ba5de66aeb85896f9d13e2914f744facbbb083c4dadc56a2031d17c996dc
6
+ metadata.gz: 1ed95ea4cee223e4f658badb1f29e99f7ae82610359fba6489d5cdbe656cd2f52b1c82a019dd1f5d60f8bf08b088b3add9c38f9c36fef52c876f7a2d40e80e65
7
+ data.tar.gz: a2aaa416a658986540e7e1d6062c971101287c6913e91840bb0a8e735bc97779ed9094486cab054b7e3440d40035a88709ddb54762660a82ca805efceec7d770
@@ -3,10 +3,13 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and
6
- this project versions are for now mere release numbers. They don't have any particular meaning.
6
+ this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
7
 
8
- This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
8
+ ## [1.0.0] - 2017-08-18
9
9
 
10
+ ### Changed
11
+
12
+ - The `Megaphone::Client` API is now stable!
10
13
 
11
14
  ## [0.3.0] - 2017-08-17
12
15
 
@@ -38,5 +41,6 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
38
41
 
39
42
  - Initial implementation of the `Megaphone::Client.publish!` method
40
43
 
44
+ [1.0.0]: https://github.com/redbubble/megaphone-client-ruby/compare/v0.1.2...v1.0.0
41
45
  [0.1.2]: https://github.com/redbubble/megaphone-client-ruby/compare/v0.1.1...v0.1.2
42
46
  [0.1.1]: https://github.com/redbubble/megaphone-client-ruby/compare/v0.1.0...v0.1.1
data/README.md CHANGED
@@ -2,6 +2,7 @@ Megaphone::Client
2
2
  =================
3
3
 
4
4
  [![Build Status](https://badge.buildkite.com/9f4fdb370f5f295ee6bf3d68937b1be2d7cf9bf65b2c7b4213.svg?branch=master)](https://buildkite.com/redbubble/megaphone-client-ruby)
5
+ [![Gem Version](https://badge.fury.io/rb/megaphone-client.svg)](https://badge.fury.io/rb/megaphone-client)
5
6
 
6
7
  Send events to Megaphone.
7
8
 
@@ -13,24 +14,45 @@ Add the gem to your `Gemfile`:
13
14
  ```ruby
14
15
  # Gemfile
15
16
 
16
- gem 'megaphone-client', '~> 0.3.0'
17
+ gem 'megaphone-client', '~> 1.0' # see semver.org
17
18
  ```
18
19
 
19
20
  Usage
20
21
  -----
21
- The client will append events to local files unless the fluentd host and port values are passed as arguments to the client's constructor or the `MEGAPHONE_FLUENT_HOST` and `MEGAPHONE_FLUENT_PORT` environment variables are set.
22
22
 
23
- To publish an event on Megaphone
24
- ```ruby
25
- event_bus = Megaphone::Client.new({ origin: 'my-awesome-service', host: 'localhost', port: '24224' })
23
+ In order to be as unobstrusive as possible, this client will append events to local files (e.g. `./work-updates.stream`) unless:
24
+
25
+ - the `MEGAPHONE_FLUENT_HOST` and `MEGAPHONE_FLUENT_PORT` environment variables are set.
26
+ - **or** the Fluentd host and port values are passed as arguments to the client's constructor
27
+
28
+ That behaviour ensures that unless you want to send events to the Megaphone [streams][stream], you do not need to [start Fluentd][megaphone-fluentd] at all.
29
+
30
+ [stream]: https://github.com/redbubble/com/megaphone#stream
31
+ [megaphone-fluentd]: https://github.com/redbubble/megaphone-fluentd-container
26
32
 
27
- topic = :page_changes
28
- subtopic = :product_pages
29
- schema = 'http://www.github.com/redbuble/megaphone-event-type-registry/topics/cats'
30
- partition_key = '1357924680'
31
- payload = { url: 'https://www.redbubble.com/people/wytrab8/works/26039653-toadally-rad?grid_pos=1&p=mens-graphic-t-shirt&rbs=29c497ad-a976-42b8-aa40-0e218903c558&ref=shop_grid&style=mens' }
33
+ ### Publishing events
32
34
 
33
- event_bus.publish!(topic, subtopic, schema, partition_key, payload)
35
+ 1. Start Fluentd, the easiest way to do so is using a [`redbubble/megaphone-fluentd`][megaphone-fluentd] container
36
+
37
+ 1. Create your event and publish it:
38
+
39
+ ```ruby
40
+ # Configure a Megaphone client for your awesome service
41
+ client = Megaphone::Client.new({
42
+ origin: 'my-awesome-service',
43
+ host: 'localhost',
44
+ port: '24224'
45
+ })
46
+
47
+ # Create an event
48
+ topic = 'work-updates'
49
+ subtopic = 'work-metadata-updated'
50
+ schema = 'https://github.com/redbubble/megaphone-event-type-registry/blob/master/streams/work-updates-schema-1.0.0.json'
51
+ partition_key = '1357924680' # the Work ID in this case
52
+ payload = { url: 'https://www.redbubble.com/people/wytrab8/works/26039653-toadally-rad' }
53
+
54
+ # Publish your event
55
+ client.publish!(topic, subtopic, schema, partition_key, payload)
34
56
  ```
35
57
 
36
58
  Credits
@@ -10,8 +10,9 @@ module Megaphone
10
10
 
11
11
  def initialize(config)
12
12
  @origin = config.fetch(:origin)
13
- @logger = Megaphone::Client::Logger.create(config[:host],
14
- config[:port])
13
+ host = config.fetch(:host, ENV['MEGAPHONE_FLUENT_HOST'])
14
+ port = config.fetch(:port, ENV['MEGAPHONE_FLUENT_PORT'])
15
+ @logger = Megaphone::Client::Logger.create(host, port)
15
16
  end
16
17
 
17
18
  def publish!(topic, subtopic, schema, partition_key, payload)
@@ -5,13 +5,11 @@ module Megaphone
5
5
  class Client
6
6
  class Logger
7
7
  def self.create(host = nil, port = nil)
8
- fluentd_host = host || ENV["MEGAPHONE_FLUENT_HOST"]
9
- fluentd_port = port || ENV["MEGAPHONE_FLUENT_PORT"]
10
- if !fluentd_port.nil? && !fluentd_port.empty? &&
11
- !fluentd_host.nil? && !fluentd_host.empty?
12
- return Megaphone::Client::FluentLogger.new(fluentd_host, fluentd_port)
8
+ if !port.nil? && !port.empty? &&
9
+ !host.nil? && !host.empty?
10
+ return FluentLogger.new(host, port)
13
11
  end
14
- Megaphone::Client::FileLogger.new
12
+ FileLogger.new
15
13
  end
16
14
  end
17
15
  end
@@ -1,5 +1,5 @@
1
1
  module Megaphone
2
2
  class Client
3
- VERSION = "0.3.0"
3
+ VERSION = "1.0.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: megaphone-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Redbubble
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-08-17 00:00:00.000000000 Z
13
+ date: 2017-08-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: fluent-logger
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  requirements: []
96
96
  rubyforge_project:
97
- rubygems_version: 2.4.5.1
97
+ rubygems_version: 2.6.12
98
98
  signing_key:
99
99
  specification_version: 4
100
100
  summary: Send events to Megaphone.