marfusha 0.0.1.pre

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fd31f00880770dad3a26ac15a81c662ca8a5c385812a2814f0b2120111a9df2b
4
+ data.tar.gz: 9f4d46f46c305bb0ce64aa40ea38322ebce610dce232ccb2746bc76fe672ed2a
5
+ SHA512:
6
+ metadata.gz: aa693e4e33cfc2c0389f32ce82d00b19731ac068558b6e1b9b8fa046ad67fe8f7c519f8237bf3914e38dd211b08b1cf5bafa8f26d2150a40294b16b821f93a00
7
+ data.tar.gz: '080b2f0c14eabe90cf3d27e52690452a67ea3b320f0502fa08222d07efb570c2e1bb9f2c8afab0f1cd60effb8c9f4ad2ede9836044b4a766280aaab5fe59f734'
@@ -0,0 +1,16 @@
1
+ .ruby-version
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ /bin/
12
+
13
+ /vendor/
14
+
15
+ *.pid
16
+ *.log
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at udzura@pepabo.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in marfusha.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Uchio KONDO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,41 @@
1
+ # Marfusha
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/marfusha`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'marfusha'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install marfusha
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/marfusha. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ here = File.dirname(__FILE__)
4
+ $LOAD_PATH << File.expand_path(File.join(here, '..', 'lib'))
5
+ require 'marfusha/cli'
@@ -0,0 +1,5 @@
1
+ require "marfusha/version"
2
+
3
+ module Marfusha
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,46 @@
1
+ require "slop"
2
+
3
+ module Marfusha
4
+ class Cli
5
+ def initialize(argv=ARGV.dup)
6
+ @argv = argv
7
+ @subcommand = @argv.shift
8
+ end
9
+
10
+ def run
11
+ case @subcommand
12
+ when "controller"
13
+ require "marfusha/controller"
14
+ opt = Slop.parse(@argv) do |o|
15
+ o.string '--loglevel', 'log level', default: 'warn'
16
+ end
17
+ Controller.new(opt).run
18
+ when "subscriber"
19
+ require "marfusha/subscriber"
20
+ opt = Slop.parse(@argv) do |o|
21
+ o.string '--loglevel', 'log level', default: 'warn'
22
+ end
23
+ Subscriber.new(opt)
24
+ when "provisioner"
25
+ require "marfusha/provisioner"
26
+ opt = Slop.parse(@argv) do |o|
27
+ o.string '--loglevel', 'log level', default: 'warn'
28
+ end
29
+ Provisioner.new(opt)
30
+ else
31
+ $stderr.puts <<~USAGE
32
+ #{$0}: valid subbcommands:
33
+ controller
34
+ provisionewr
35
+ subscriber
36
+ Showing more info with --help option with each subcommand
37
+ ---
38
+ USAGE
39
+ raise "Invalid subcommand: #{ARGV.inspect}"
40
+ # TODO: usage
41
+ end
42
+ end
43
+ end
44
+ end
45
+
46
+ exit Marfusha::Cli.new.run
@@ -0,0 +1,55 @@
1
+ require "serverengine"
2
+ require "ffi-rzmq"
3
+
4
+ module Marfusha
5
+ class Controller
6
+ def initialize(opt)
7
+ end
8
+
9
+ def run
10
+ options = {
11
+ daemonize: false,
12
+ supervisor: true,
13
+ log: '/dev/stdout',
14
+ pid_path: './conrtoller.pid',
15
+ worker_type: 'process',
16
+ workers: 1,
17
+ bind: '0.0.0.0',
18
+ port: 8311,
19
+ worker_process_name: 'marfusha: controller worker'
20
+ }
21
+ s = ServerEngine.create(nil, Worker, options)
22
+ s.run
23
+ return 0
24
+ end
25
+
26
+ module Worker
27
+ def run
28
+ logger.info("This is controller!!")
29
+ @running = true
30
+ @ctx = ZMQ::Context.new
31
+ @socket = @ctx.socket(ZMQ::REP)
32
+ zmq_assert(@socket.setsockopt(ZMQ::LINGER, 100))
33
+ zmq_assert(@socket.bind("tcp://127.0.0.1:8311"))
34
+
35
+ while @running
36
+ msg = ""
37
+ if @socket.recv_string(msg, ZMQ::DONTWAIT) > 0
38
+ logger.info("Got message!! #{msg.inspect}")
39
+ zmq_assert(@socket.send_string("OK", ZMQ::DONTWAIT))
40
+ end
41
+ sleep 1
42
+ end
43
+ end
44
+
45
+ def stop
46
+ @running = false
47
+ end
48
+
49
+ private
50
+ def zmq_assert(rc)
51
+ raise "Last API call failed at #{caller(1)}" unless rc >= 0
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,130 @@
1
+ require "serverengine"
2
+
3
+ module Marfusha
4
+ module PublisherProvisioner
5
+ def before_run
6
+ end
7
+ end
8
+
9
+ class PublisherServer
10
+ include Celluloid::IO
11
+ finalizer :finalize
12
+ def initialize(host, port)
13
+ puts "*** Starting echo server on #{host}:#{port}"
14
+
15
+ # Since we included Celluloid::IO, we're actually making a
16
+ # Celluloid::IO::TCPServer here
17
+ @server = TCPServer.new(host, port)
18
+ async.run
19
+ end
20
+
21
+ def finalize
22
+ @server.close if @server
23
+ end
24
+
25
+ def run
26
+ loop { async.handle_connection @server.accept }
27
+ end
28
+
29
+ def handle_connection(socket)
30
+ _, port, host = socket.peeraddr
31
+ puts "*** Received connection from #{host}:#{port}"
32
+ socket.write "I am publisher!!1"
33
+ loop do
34
+ p = socket.readpartial(4096)
35
+ socket.write p
36
+ if p.end_with? "\n"
37
+ puts "*** #{host}:#{port} closed connection"
38
+ socket.close
39
+ break
40
+ end
41
+ end
42
+ rescue EOFError
43
+ puts "*** #{host}:#{port} disconnected"
44
+ socket.close
45
+ end
46
+ end
47
+
48
+ module PublisherWorker
49
+ def initialize
50
+ require "celluloid/autostart"
51
+ end
52
+
53
+ def run
54
+ puts "Run Server!!!1"
55
+ @runner = PublisherServer.new(config[:bind], config[:port])
56
+ @alive = true
57
+ puts "Server is now listening"
58
+ while @alive
59
+ sleep 0.01
60
+ end
61
+ end
62
+
63
+ def stop
64
+ puts "Accept stop"
65
+ @runner.terminate if @runner
66
+ rescue ::Celluloid::DeadActorError => e
67
+ puts "Detect error #{e.inspect} and skip"
68
+ ensure
69
+ @alive = false
70
+ end
71
+ end
72
+
73
+ module Subscriber
74
+ def before_run
75
+ @sock = TCPServer.new(config[:bind], config[:port])
76
+ end
77
+
78
+ attr_reader :sock
79
+ end
80
+
81
+ module SubscriberWorker
82
+ def run
83
+ until @stop
84
+ # you should use Cool.io or EventMachine actually
85
+ c = server.sock.accept
86
+ c.write "This is subscriber!\n"
87
+ c.close
88
+ end
89
+ end
90
+
91
+ def stop
92
+ @stop = true
93
+ end
94
+ end
95
+ end
96
+
97
+ case ARGV[0]
98
+ when "publisher"
99
+ options = {
100
+ daemonize: true,
101
+ supervisor: true,
102
+ log: '/tmp/pub.log',
103
+ pid_path: '/tmp/pub.pid',
104
+ worker_type: 'process',
105
+ workers: 1,
106
+ bind: '0.0.0.0',
107
+ port: 8310,
108
+ server_process_name: 'marfusha: publisher',
109
+ worker_process_name: 'marfusha: publisher worker',
110
+ }
111
+ eng = ServerEngine.create(Marfusha::PublisherProvisioner, Marfusha::PublisherWorker, options)
112
+ eng.run
113
+ when "subscriber"
114
+ options = {
115
+ daemonize: true,
116
+ supervisor: true,
117
+ log: '/tmp/sub.log',
118
+ pid_path: '/tmp/sub.pid',
119
+ worker_type: 'process',
120
+ workers: 1,
121
+ bind: '0.0.0.0',
122
+ port: 8311,
123
+ daemon_process_name: 'marfusha: subscriber',
124
+ worker_process_name: 'marfusha: subscriber worker',
125
+ }
126
+ eng = ServerEngine.create(Marfusha::Subscriber, Marfusha::SubscriberWorker, options)
127
+ eng.run
128
+ else
129
+ raise "Invalid arg: #{ARGV.inspect}"
130
+ end
@@ -0,0 +1,34 @@
1
+ require "serverengine"
2
+
3
+ module Marfusha
4
+ class Provisioner
5
+ def initialize(opt)
6
+ end
7
+
8
+ def run
9
+ options = {
10
+ daemonize: false,
11
+ supervisor: true,
12
+ log: '/dev/stdout',
13
+ pid_path: './conrtoller.pid',
14
+ worker_type: 'process',
15
+ workers: 1,
16
+ bind: '0.0.0.0',
17
+ port: 8311,
18
+ worker_process_name: 'marfusha: controller worker'
19
+ }
20
+ s = ServerEngine.create(nil, Worker, options)
21
+ s.run
22
+ return 0
23
+ end
24
+
25
+ module Worker
26
+ def run
27
+ logger.info("This is controller!!")
28
+ loop do
29
+ sleep 1
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,34 @@
1
+ require "serverengine"
2
+
3
+ module Marfusha
4
+ class Subscriber
5
+ def initialize(opt)
6
+ end
7
+
8
+ def run
9
+ options = {
10
+ daemonize: false,
11
+ supervisor: true,
12
+ log: '/dev/stdout',
13
+ pid_path: './conrtoller.pid',
14
+ worker_type: 'process',
15
+ workers: 1,
16
+ bind: '0.0.0.0',
17
+ port: 8311,
18
+ worker_process_name: 'marfusha: controller worker'
19
+ }
20
+ s = ServerEngine.create(nil, Worker, options)
21
+ s.run
22
+ return 0
23
+ end
24
+
25
+ module Worker
26
+ def run
27
+ logger.info("This is controller!!")
28
+ loop do
29
+ sleep 1
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Marfusha
2
+ VERSION = "0.0.1.pre"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'marfusha/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "marfusha"
8
+ spec.version = Marfusha::VERSION
9
+ spec.authors = ["Uchio KONDO"]
10
+ spec.email = ["udzura@udzura.jp"]
11
+
12
+ spec.summary = %q{A containers orchestrator aiming to the space!}
13
+ spec.description = spec.summary
14
+ spec.homepage = "https://github.com/udzura/marfusha"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
18
+ f.match(%r{^(test|spec|features)/})
19
+ end
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_runtime_dependency "ffi-rzmq"
25
+ spec.add_runtime_dependency "serverengine"
26
+ spec.add_runtime_dependency "slop"
27
+ spec.add_runtime_dependency "celluloid-io"
28
+ spec.add_development_dependency "bundler", "~> 1.13"
29
+ spec.add_development_dependency "rake", "~> 10.0"
30
+ end
metadata ADDED
@@ -0,0 +1,146 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: marfusha
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre
5
+ platform: ruby
6
+ authors:
7
+ - Uchio KONDO
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-05-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: ffi-rzmq
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: serverengine
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: slop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: celluloid-io
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.13'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.13'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '10.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '10.0'
97
+ description: A containers orchestrator aiming to the space!
98
+ email:
99
+ - udzura@udzura.jp
100
+ executables:
101
+ - marfd
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - CODE_OF_CONDUCT.md
107
+ - Gemfile
108
+ - LICENSE.txt
109
+ - README.md
110
+ - Rakefile
111
+ - bin/console
112
+ - bin/setup
113
+ - exe/marfd
114
+ - lib/marfusha.rb
115
+ - lib/marfusha/cli.rb
116
+ - lib/marfusha/controller.rb
117
+ - lib/marfusha/daemon.rb
118
+ - lib/marfusha/provisioner.rb
119
+ - lib/marfusha/subscriber.rb
120
+ - lib/marfusha/version.rb
121
+ - marfusha.gemspec
122
+ homepage: https://github.com/udzura/marfusha
123
+ licenses:
124
+ - MIT
125
+ metadata: {}
126
+ post_install_message:
127
+ rdoc_options: []
128
+ require_paths:
129
+ - lib
130
+ required_ruby_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - ">"
138
+ - !ruby/object:Gem::Version
139
+ version: 1.3.1
140
+ requirements: []
141
+ rubyforge_project:
142
+ rubygems_version: 2.7.6
143
+ signing_key:
144
+ specification_version: 4
145
+ summary: A containers orchestrator aiming to the space!
146
+ test_files: []