|
Revision 326, 0.5 kB
(checked in by gethema..@gmail.com, 6 months ago)
|
check in new backgroundrb code
|
| Line | |
|---|
| 1 |
class LogWorker < Packet::Worker |
|---|
| 2 |
set_worker_name :log_worker |
|---|
| 3 |
attr_accessor :log_file |
|---|
| 4 |
def worker_init |
|---|
| 5 |
@log_file = Logger.new("#{RAILS_HOME}/log/backgroundrb_#{BDRB_CONFIG[:backgroundrb][:port]}.log") |
|---|
| 6 |
end |
|---|
| 7 |
|
|---|
| 8 |
def receive_data p_data |
|---|
| 9 |
case p_data[:type] |
|---|
| 10 |
when :request: process_request(p_data) |
|---|
| 11 |
when :response: process_response(p_data) |
|---|
| 12 |
end |
|---|
| 13 |
end |
|---|
| 14 |
|
|---|
| 15 |
def process_request(p_data) |
|---|
| 16 |
log_data = p_data[:data] |
|---|
| 17 |
@log_file.info(log_data) |
|---|
| 18 |
end |
|---|
| 19 |
|
|---|
| 20 |
def process_response |
|---|
| 21 |
puts "Not implemented and needed" |
|---|
| 22 |
end |
|---|
| 23 |
end |
|---|
| 24 |
|
|---|
| 25 |
|
|---|