Skip to content

Commit

Permalink
adds #default_logger to RedisStream (#4)
Browse files Browse the repository at this point in the history
* adds #default_logger to RedisStream

* allows setting the loggin_stream_key
  • Loading branch information
jeanmartin authored Jun 26, 2024
1 parent 5a35551 commit 6c9727d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
redis_stream (0.1.2)
redis_stream (0.1.3)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 4 additions & 0 deletions lib/redis_stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,8 @@ def self.client
def self.default_publisher
@default_publisher ||= Publisher.new(config.stream_key)
end

def self.default_logger
@default_logger ||= Publisher.new(config.logging_stream_key)
end
end
7 changes: 6 additions & 1 deletion lib/redis_stream/configuration.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
module RedisStream
class Configuration
attr_accessor :client, :group_id, :consumer_id, :stream_key
attr_accessor :client, :group_id, :consumer_id, :stream_key, :logging_stream_key

def initialize
@group = "group"
@consumer = "consumer"
@stream_key = "stream"
@logging_stream_key = "logging_stream"
end

def redis(client)
Expand All @@ -27,5 +28,9 @@ def consumer(consumer_id)
def stream(stream)
@stream_key = stream
end

def logging_stream(logging_stream)
@logging_stream_key = logging_stream
end
end
end
2 changes: 1 addition & 1 deletion lib/redis_stream/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module RedisStream
VERSION = "0.1.2"
VERSION = "0.1.3"
end
10 changes: 10 additions & 0 deletions spec/redis_stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,14 @@
expect(RedisStream.client).to be_instance_of(DummyRedisClient)
end
end

describe ".default_logger" do
it "returns a Publisher instance" do
expect(RedisStream.default_logger).to be_instance_of(RedisStream::Publisher)
end

it "uses the logging stream key" do
expect(RedisStream.default_logger.instance_variable_get(:@stream_key)).to eq("logging_stream")
end
end
end

0 comments on commit 6c9727d

Please sign in to comment.