class Miu::Nodes::Sana::Node
Constants
- DEFAULT_PORT
Attributes
options[R]
server[R]
subscriber[R]
Public Class Methods
new(options)
click to toggle source
# File lib/miu/nodes/sana/node.rb, line 20 def initialize(options) @options = options Miu::Logger.info "Options:" @options.each do |k, v| Miu::Logger.info " #{k}: #{v}" end establish options[:database] @server = Server.new options[:bind], options[:port] @subscriber = Subscriber.new options['sub-host'], options['sub-port'], options['sub-tag'] @subscriber.async.run [:INT, :TERM].each do |sig| trap(sig) { exit } end sleep end
Private Instance Methods
establish(path)
click to toggle source
# File lib/miu/nodes/sana/node.rb, line 43 def establish(path) FileUtils.mkdir_p File.dirname(path) ::Groonga::Context.default_options = {:encoding => :utf8} if File.exist? path ::Groonga::Database.open path else ::Groonga::Database.create :path => path end ::Groonga::Schema.define do |schema| schema.create_table 'networks', :type => :patricia_trie, :key_type => :short_text schema.create_table 'rooms', :type => :patricia_trie, :key_type => :short_text schema.create_table 'users', :type => :patricia_trie, :key_type => :short_text schema.create_table 'messages', :type => :array schema.create_table 'terms', :type => :patricia_trie, :key_normalize => true, :default_tokenizer => :bigram schema.change_table 'networks' do |table| table.short_text 'name' end schema.change_table 'rooms' do |table| table.reference 'network', 'networks' table.short_text 'name' end schema.change_table 'users' do |table| table.reference 'network', 'networks' table.short_text 'name' end schema.change_table 'messages' do |table| table.reference 'network', 'networks' table.reference 'room', 'rooms' table.reference 'user', 'users' table.short_text 'text' table.short_text 'meta' table.time 'time' end schema.change_table 'terms' do |table| table.index 'networks.name' table.index 'rooms.name' table.index 'users.name' table.index 'messages.text' end end end
init()
click to toggle source
# File lib/miu/nodes/sana/node.rb, line 99 def init config <<-EOS Miu.watch 'sana' do |w| w.start = 'miu sana start' w.keepalive end EOS end
start()
click to toggle source
# File lib/miu/nodes/sana/node.rb, line 94 def start Node.new options end