Skip to content

Commit

Permalink
Move data type method conditional outside of loop
Browse files Browse the repository at this point in the history
  • Loading branch information
hectcastro authored and Hector Castro committed Jun 10, 2015
1 parent b970bda commit 94812db
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions beaver/transports/redis_transport.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,18 @@ def callback(self, filename, lines, **kwargs):

pipeline = server['redis'].pipeline(transaction=False)

if data_type == 'list':
data_type_method = pipeline.rpush
elif data_type == 'channel':
data_type_method = pipeline.publish
else:
raise TransportException('Unknown Redis data type')

for line in lines:
if data_type == 'list':
pipeline.rpush(
namespace,
self.format(filename, line, timestamp, **kwargs)
)
elif data_type == 'channel':
pipeline.publish(
namespace,
self.format(filename, line, timestamp, **kwargs)
)
else:
raise TransportException('Unknown Redis data type')
data_type_method(
namespace,
self.format(filename, line, timestamp, **kwargs)
)

try:
pipeline.execute()
Expand Down

0 comments on commit 94812db

Please sign in to comment.