Class: FreeMessageQueue::FileQueue
- Inherits:
-
Object
- Object
- FreeMessageQueue::FileQueue
- Defined in:
- lib/fmq/queues/file.rb
Overview
This queue returns everytime the same file. This is useful during debugging or to serve the admin page.
configuration sample:
queue-manager:
auto-create-queues: true
defined-queues:
admin-page-index:
path: /admin/index
class: FreeMessageQueue::FileQueue
file: admin-interface/index.html
content-type: text/html
NOTE the put method is not implemented in this queue. It is a poll only queue.
Instance Attribute Summary collapse
-
#bytes ⇒ Object
readonly
Bytes are -1 at startup but fill after first poll.
-
#manager ⇒ Object
QueueManager refrence.
-
#size ⇒ Object
readonly
Bytes are -1 at startup but fill after first poll.
Instance Method Summary collapse
-
#content_type=(type) ⇒ Object
CONFIGURATION OPTION sets the content_type of the file.
-
#file=(path) ⇒ Object
CONFIGURATION OPTION sets the path to the file that should be read.
-
#initialize ⇒ FileQueue
constructor
A new instance of FileQueue.
-
#poll ⇒ Object
Return the file and content type.
Constructor Details
#initialize ⇒ FileQueue
Returns a new instance of FileQueue.
41 42 43 44 45 |
# File 'lib/fmq/queues/file.rb', line 41 def initialize # there is always one message (the file) in the queue @bytes = -1 @size = 1 end |
Instance Attribute Details
#bytes ⇒ Object (readonly)
Bytes are -1 at startup but fill after first poll. Size is allways 1 message
39 40 41 |
# File 'lib/fmq/queues/file.rb', line 39 def bytes @bytes end |
#manager ⇒ Object
QueueManager refrence
36 37 38 |
# File 'lib/fmq/queues/file.rb', line 36 def manager @manager end |
#size ⇒ Object (readonly)
Bytes are -1 at startup but fill after first poll. Size is allways 1 message
39 40 41 |
# File 'lib/fmq/queues/file.rb', line 39 def size @size end |
Instance Method Details
#content_type=(type) ⇒ Object
CONFIGURATION OPTION sets the content_type of the file. This option make sense if you want to test with the webbrowser.
69 70 71 |
# File 'lib/fmq/queues/file.rb', line 69 def content_type=(type) @content_type = type end |
#file=(path) ⇒ Object
CONFIGURATION OPTION sets the path to the file that should be read
62 63 64 |
# File 'lib/fmq/queues/file.rb', line 62 def file=(path) @file_path = path end |
#poll ⇒ Object
Return the file and content type
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/fmq/queues/file.rb', line 48 def poll() item = OpenStruct.new f = open(@file_path, "rb") item.data = f.read @bytes = item.data.size f.close item.content_type = @content_type item end |