armstrong 0.2.1 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ gem 'lazy'
2
+ gem 'open-uri'
3
+ gem 'ffi'
4
+ gem 'ffi-rzmq'
data/README.md CHANGED
@@ -16,9 +16,13 @@ This is possible because of Mongrel2 and ZeroMQ. Mongrel2 acts as your server an
16
16
  Go grab the zip from [zeromq/zeromq2-1](https://github.com/zeromq/zeromq2-1), unzip it, and in the directory run:
17
17
 
18
18
  ./autogen.sh; ./configure; make; sudo make install
19
+
20
+ #### Armstrong as a gem ####
21
+
22
+ gem install armstrong
19
23
 
20
24
  #### ZMQ and other gems ####
21
- gem install zmq
25
+ gem install ffi-rzmq
22
26
  gem install lazy
23
27
 
24
28
  it should also install `ffi` and `ffi-rzmq` which are to dynamically load libs and call functions from them. Interesting stuff, but out of the scope of this measly README.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ desc "Push actors to github, switch to master, merge actors, push master to github"
2
+ namespace :super do
3
+ task :push do
4
+ `git push github`
5
+ `go master`
6
+ `git merge actors`
7
+ `git push github`
8
+ `go actors`
9
+ end
10
+ end
11
+
12
+ namespace :g do
13
+ desc "Build gem"
14
+ task :b do
15
+ `gem build armstrong.gemspec`
16
+ end
17
+
18
+ desc "Push gem"
19
+ task :p do
20
+ Rake::Task["g:b"].invoke
21
+ gem_file = `ls *.gem`.to_a.first
22
+ puts "pushing #{gem_file}"
23
+ gets
24
+ `gem push #{gem_file}`
25
+ end
26
+ end
data/armstrong.gemspec ADDED
@@ -0,0 +1,12 @@
1
+ Gem::Specification.new 'armstrong', '0.2.4' do |s|
2
+ s.description = "Armstrong is an Mongrel2 fronted, actor-based web development framework similar in style to sinatra. With natively-threaded interpreters (Rubinius2), Armstrong provides true concurrency and high stability, by design."
3
+ s.summary = "Highly concurrent, sinatra-like framework"
4
+ s.author = "Artem Titoulenko"
5
+ s.email = "artem.titoulenko@gmail.com"
6
+ s.homepage = "https://www.github.com/artemtitoulenko/armstrong"
7
+ s.files = `git ls-files`.split("\n") - %w[.gitignore .travis.yml response_benchmark.rb demo/config.sqlite]
8
+
9
+ s.add_dependency 'ffi', '~> 1.0', '>= 1.0.10'
10
+ s.add_dependency 'ffi-rzmq', '~> 0.9', '>= 0.9.0'
11
+ s.add_dependency 'lazy', '>= 0.9.6'
12
+ end
@@ -25,21 +25,19 @@ class Connection
25
25
  def recv
26
26
  msg = ""
27
27
  @request_sock.recv_string msg
28
- return msg
28
+ msg
29
29
  end
30
30
 
31
31
  #parse the request, this is the best way to get stuff back, as a Hash
32
32
  def receive
33
- data = parse(self.recv)
34
- return data
33
+ parse(self.recv)
35
34
  end
36
35
 
37
36
  def send(uuid, conn_id, msg)
38
37
  header = "%s %d:%s" % [uuid, conn_id.join(' ').length, conn_id.join(' ')]
39
38
  string = header + ', ' + msg
40
- puts "\t\treplying to #{conn_id} with: ", string.inspect
39
+ #puts "\t\treplying to #{conn_id} with: ", string
41
40
  @response_sock.send_string string, ZMQ::NOBLOCK
42
- puts "send string"
43
41
  end
44
42
 
45
43
  def reply(request, message)
@@ -60,7 +58,6 @@ class Connection
60
58
 
61
59
  def parse(msg)
62
60
  if(msg.empty?)
63
- puts "msg is nil: [#{msg}]"
64
61
  return nil
65
62
  end
66
63
 
@@ -14,7 +14,7 @@ def process_route(route, pattern, keys, values = [])
14
14
  if values.any?
15
15
  keys.zip(values) { |k,v| (params[k] ||= '') << v if v }
16
16
  end
17
- return params
17
+ params
18
18
  end
19
19
 
20
20
  Aleph::Base.replier = Proc.new do
@@ -73,12 +73,12 @@ Aleph::Base.request_handler = Proc.new do
73
73
  failure = false
74
74
  end
75
75
  end
76
- Actor[:replier] << Reply.new(r.data, "404") if failure
76
+ Actor[:replier] << Reply.new(r.data, "404", 404, {'Content-type'=>'text/html'}) if failure
77
77
  end
78
78
 
79
- f.when(Actor::DeadActorError) do |exit|
80
- puts "#{exit.actor} died with reason: [#{exit.reason}]"
81
- end
79
+ # f.when(Actor::DeadActorError) do |exit|
80
+ # puts "#{exit.actor} died with reason: [#{exit.reason}]"
81
+ # end
82
82
  end
83
83
  end
84
84
  end
data/lib/armstrong.rb CHANGED
@@ -105,13 +105,13 @@ module Aleph
105
105
  done = true
106
106
  end)
107
107
 
108
- puts "","="*56,"Armstrong has launched on #{Time.now}","="*56, "" if done
108
+ if Actor[:supervisor] && Actor[:request_handler] && Actor[:replier] && done
109
+ puts "","="*56,"Armstrong has launched on #{Time.now}","="*56, ""
110
+ end
109
111
 
110
- puts "s:#{Actor[:supervisor]} h:#{Actor[:request_handler]} r: #{Actor[:replier]}"
111
112
  # main loop
112
113
  loop do
113
114
  req = @conn.receive
114
- puts "s:#{Actor[:supervisor]} h:#{Actor[:request_handler]} r: #{Actor[:replier]}"
115
115
  Actor[:request_handler] << Request.new(req) if !req.nil?
116
116
  end
117
117
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: armstrong
3
3
  version: !ruby/object:Gem::Version
4
- hash: 2998277272998775549
4
+ hash: 62131057062410167
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 4
10
+ version: 0.2.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Artem Titoulenko
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-06 00:00:00 Z
18
+ date: 2011-11-08 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: ffi
@@ -88,7 +88,10 @@ extensions: []
88
88
  extra_rdoc_files: []
89
89
 
90
90
  files:
91
+ - Gemfile
91
92
  - README.md
93
+ - Rakefile
94
+ - armstrong.gemspec
92
95
  - demo/armstrong_test.rb
93
96
  - demo/mongrel2.conf
94
97
  - lib/armstrong.rb