Class: FreeMessageQueue::FileQueue

Inherits:
BaseQueue
  • Object
show all
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.

Constant Summary

Constants inherited from BaseQueue

BaseQueue::INFINITE

Instance Attribute Summary

Attributes inherited from BaseQueue

#bytes, #manager, #max_messages, #max_size, #size

Instance Method Summary collapse

Methods inherited from BaseQueue

#empty?, #initialize

Constructor Details

This class inherits a constructor from FreeMessageQueue::BaseQueue

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.



56
57
58
# File 'lib/fmq/queues/file.rb', line 56

def content_type=(type)
  @content_type = type
end

#file=(path) ⇒ Object

CONFIGURATION OPTION sets the path to the file that should be read



49
50
51
# File 'lib/fmq/queues/file.rb', line 49

def file=(path)
  @file_path = path
end

#pollObject

Return the file and content type



38
39
40
41
42
43
44
45
# File 'lib/fmq/queues/file.rb', line 38

def poll()
  f = open(@file_path, "rb")
  file_content = f.read
  f.close
  
  @bytes = file_content.size
  Message.new(file_content, @content_type)
end