cztop 1.1.2 → 1.2.1

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.
data/.rubocop.yml DELETED
@@ -1,175 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.7
3
- NewCops: enable
4
- Layout/EmptyLineAfterMagicComment:
5
- Enabled: true
6
- Layout/ExtraSpacing:
7
- AllowForAlignment: true
8
- Layout/EmptyLines:
9
- Enabled: false
10
- Layout/EmptyLineBetweenDefs:
11
- NumberOfEmptyLines: 2
12
- Layout/MultilineOperationIndentation:
13
- Enabled: true
14
- Gemspec/DeprecatedAttributeAssignment: # new in 1.30
15
- Enabled: true
16
- Gemspec/RequireMFA: # new in 1.23
17
- Enabled: true
18
- Layout/LineContinuationLeadingSpace: # new in 1.31
19
- Enabled: true
20
- Layout/LineContinuationSpacing: # new in 1.31
21
- Enabled: true
22
- Layout/LineEndStringConcatenationIndentation: # new in 1.18
23
- Enabled: true
24
- Layout/SpaceBeforeBrackets: # new in 1.7
25
- Enabled: true
26
- Lint/AmbiguousAssignment: # new in 1.7
27
- Enabled: true
28
- Lint/AmbiguousOperatorPrecedence: # new in 1.21
29
- Enabled: false
30
- Lint/AmbiguousRange: # new in 1.19
31
- Enabled: true
32
- Lint/ConstantOverwrittenInRescue: # new in 1.31
33
- Enabled: true
34
- Lint/DeprecatedConstants: # new in 1.8
35
- Enabled: true
36
- Lint/DuplicateBranch: # new in 1.3
37
- Enabled: true
38
- Lint/DuplicateRegexpCharacterClassElement: # new in 1.1
39
- Enabled: true
40
- Lint/EmptyBlock: # new in 1.1
41
- Enabled: true
42
- Lint/EmptyClass: # new in 1.3
43
- Enabled: true
44
- Lint/EmptyInPattern: # new in 1.16
45
- Enabled: true
46
- Lint/IncompatibleIoSelectWithFiberScheduler: # new in 1.21
47
- Enabled: true
48
- Lint/LambdaWithoutLiteralBlock: # new in 1.8
49
- Enabled: true
50
- Lint/NoReturnInBeginEndBlocks: # new in 1.2
51
- Enabled: true
52
- Lint/NonAtomicFileOperation: # new in 1.31
53
- Enabled: true
54
- Lint/NumberedParameterAssignment: # new in 1.9
55
- Enabled: true
56
- Lint/OrAssignmentToConstant: # new in 1.9
57
- Enabled: true
58
- Lint/RedundantDirGlobSort: # new in 1.8
59
- Enabled: true
60
- Lint/RefinementImportMethods: # new in 1.27
61
- Enabled: true
62
- Lint/RequireRangeParentheses: # new in 1.32
63
- Enabled: true
64
- Lint/RequireRelativeSelfPath: # new in 1.22
65
- Enabled: true
66
- Lint/SymbolConversion: # new in 1.9
67
- Enabled: true
68
- Lint/ToEnumArguments: # new in 1.1
69
- Enabled: true
70
- Lint/TripleQuotes: # new in 1.9
71
- Enabled: true
72
- Lint/UnexpectedBlockArity: # new in 1.5
73
- Enabled: true
74
- Lint/UnmodifiedReduceAccumulator: # new in 1.1
75
- Enabled: true
76
- Lint/UselessRuby2Keywords: # new in 1.23
77
- Enabled: true
78
- Naming/BlockForwarding: # new in 1.24
79
- Enabled: true
80
- Security/CompoundHash: # new in 1.28
81
- Enabled: true
82
- Security/IoMethods: # new in 1.22
83
- Enabled: true
84
- Style/AndOr:
85
- EnforcedStyle: conditionals
86
- Style/InfiniteLoop:
87
- Enabled: false
88
- Style/ArgumentsForwarding: # new in 1.1
89
- Enabled: true
90
- Style/CollectionCompact: # new in 1.2
91
- Enabled: true
92
- Style/DocumentDynamicEvalDefinition: # new in 1.1
93
- Enabled: true
94
- Style/EmptyHeredoc: # new in 1.32
95
- Enabled: true
96
- Style/EndlessMethod: # new in 1.8
97
- Enabled: true
98
- Style/EnvHome: # new in 1.29
99
- Enabled: true
100
- Style/FetchEnvVar: # new in 1.28
101
- Enabled: true
102
- Style/FileRead: # new in 1.24
103
- Enabled: true
104
- Style/FileWrite: # new in 1.24
105
- Enabled: true
106
- Style/FrozenStringLiteralComment:
107
- EnforcedStyle: always_true
108
- Style/HashConversion: # new in 1.10
109
- Enabled: true
110
- Style/HashExcept: # new in 1.7
111
- Enabled: true
112
- Style/IfWithBooleanLiteralBranches: # new in 1.9
113
- Enabled: true
114
- Style/InPatternThen: # new in 1.16
115
- Enabled: true
116
- Style/MagicCommentFormat: # new in 1.35
117
- Enabled: true
118
- Style/MapCompactWithConditionalBlock: # new in 1.30
119
- Enabled: true
120
- Style/MapToHash: # new in 1.24
121
- Enabled: true
122
- Style/MultilineInPatternThen: # new in 1.16
123
- Enabled: true
124
- Style/NegatedIfElseCondition: # new in 1.2
125
- Enabled: true
126
- Style/NestedFileDirname: # new in 1.26
127
- Enabled: true
128
- Style/NilLambda: # new in 1.3
129
- Enabled: true
130
- Style/NumberedParameters: # new in 1.22
131
- Enabled: true
132
- Style/NumberedParametersLimit: # new in 1.22
133
- Enabled: true
134
- Style/ObjectThen: # new in 1.28
135
- Enabled: true
136
- Style/OpenStructUse: # new in 1.23
137
- Enabled: true
138
- Style/QuotedSymbols: # new in 1.16
139
- Enabled: true
140
- Style/RedundantArgument: # new in 1.4
141
- Enabled: true
142
- Style/RedundantInitialize: # new in 1.27
143
- Enabled: true
144
- Style/RedundantSelfAssignmentBranch: # new in 1.19
145
- Enabled: true
146
- Style/SelectByRegexp: # new in 1.22
147
- Enabled: true
148
- Style/StringChars: # new in 1.12
149
- Enabled: true
150
- Style/SwapValues: # new in 1.1
151
- Enabled: true
152
- Style/ClassAndModuleChildren:
153
- Enabled: false
154
- Style/StringConcatenation:
155
- Enabled: false
156
- Style/RescueModifier:
157
- Enabled: false
158
- Style/YodaCondition:
159
- Enabled: false
160
- Lint/AmbiguousRegexpLiteral:
161
- Enabled: false
162
- Style/WordArray:
163
- Enabled: false
164
- Style/Semicolon:
165
- Enabled: false
166
- Naming/MethodName:
167
- Enabled: false
168
- Style/EmptyMethod:
169
- Enabled: false
170
- Layout/EmptyLinesAroundClassBody:
171
- Enabled: true
172
- EnforcedStyle: empty_lines_except_namespace
173
- Layout/EmptyLinesAroundModuleBody:
174
- Enabled: true
175
- EnforcedStyle: empty_lines_except_namespace
data/.yardopts DELETED
@@ -1 +0,0 @@
1
- --private lib/**/*.rb - README.md LICENSE
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
data/ci/install-libczmq DELETED
@@ -1,22 +0,0 @@
1
- #!/bin/sh -x
2
- # vim: ft=sh
3
- set -e
4
- mkdir -p ~/src
5
- cd ~/src
6
-
7
- case "$CZMQ_VERSION" in
8
- HEAD)
9
- echo "Using HEAD and compiling with --enable-drafts ..."
10
- git clone https://github.com/zeromq/czmq czmq
11
- CONFIGURE_OPTS="--enable-drafts=yes"
12
- ;;
13
- *)
14
- echo '$CZMQ_VERSION not set.'
15
- exit 1
16
- esac
17
-
18
- cd czmq
19
- ./autogen.sh
20
- ./configure --prefix=$HOME $CONFIGURE_OPTS
21
- make
22
- make install
data/ci/install-libzmq DELETED
@@ -1,22 +0,0 @@
1
- #!/bin/sh -x
2
- # vim: ft=sh
3
- set -e
4
- mkdir -p ~/src
5
- cd ~/src
6
-
7
- case "$ZMQ_VERSION" in
8
- HEAD)
9
- echo "Using HEAD and compiling with --enable-drafts ..."
10
- git clone https://github.com/zeromq/libzmq libzmq
11
- CONFIGURE_OPTS="--enable-drafts=yes"
12
- ;;
13
- *)
14
- echo '$ZMQ_VERSION not set.'
15
- exit 1
16
- esac
17
-
18
- cd libzmq
19
- ./autogen.sh
20
- ./configure --prefix=$HOME $CONFIGURE_OPTS
21
- make
22
- make install
@@ -1,100 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'cztop'
3
-
4
- ##
5
- # This example shows how to create a simple actor using a Ruby block.
6
- # Of course it also supports the CZMQ-native way, passing a pointer to
7
- # a C function. That's how CZTop::Beacon, CZTop::Authenticator, ... are
8
- # implemented.
9
- #
10
-
11
- counter = 0
12
- actor = CZTop::Actor.new do |msg, pipe|
13
- # This block is called once for every received message.
14
-
15
- case command = msg[0]
16
- when "UPCASE"
17
- # Upcase second message frame and send back.
18
- word = msg[1]
19
- puts ">>> Actor converts #{word.inspect} to uppercase."
20
- pipe << word.upcase
21
- when "COUNT"
22
- # Count up.
23
- counter += 1
24
- puts ">>> Actor has incremented counter to: #{counter}"
25
- when "PRODUCE"
26
- # Produce multiple messages.
27
- num = msg[1].to_i
28
- puts ">>> Actor produces #{num} messages."
29
- num.times { |i| pipe << "FOO #{i+1}/#{num}" }
30
- else
31
- # crashes actor #=> Actor#dead? and Actor#crashed? will return true
32
- # also, Actor#exception will return this exception.
33
- raise "invalid command: #{command}"
34
- end
35
- end
36
- puts ">>> Actor created."
37
-
38
- ##
39
- # Let actor count.
40
- #
41
- # Actor#<< is thread-safe.
42
- #
43
- actor << "COUNT"
44
- actor << "COUNT"
45
- actor << "COUNT"
46
- actor << "COUNT"
47
- actor << "COUNT"
48
- actor << "COUNT"
49
-
50
-
51
- ##
52
- # Request a response from actor.
53
- #
54
- # Actor#request is thread-safe and ensures that the right response gets
55
- # returned.
56
- #
57
- puts actor.request(["UPCASE", "foobar"]).inspect
58
- #=> #<CZTop::Message:0x7f98c8d96000 frames=1 content_size=6 content=["FOOBAR"]>
59
-
60
-
61
- ##
62
- # Let actor produce some messages.
63
- #
64
- # Actor#receive is thread-safe, but doesn't guarantee any particular order.
65
- #
66
- actor << %w[ PRODUCE 5 ]
67
- puts actor.receive[0] #1
68
- puts actor.receive[0] #2
69
- puts actor.receive[0] #3
70
- puts actor.receive[0] #4
71
- puts actor.receive[0] #5
72
-
73
- ##
74
- # Let actor die.
75
- #
76
- # Blocks until dead.
77
- actor.terminate
78
- actor.dead? #=> true
79
- actor.crashed? #=> false
80
- actor.exception #=> nil, because it didn't crash
81
-
82
-
83
- __END__
84
- Example output:
85
-
86
- >>> Actor created.
87
- >>> Actor has incremented counter to: 1
88
- >>> Actor has incremented counter to: 2
89
- >>> Actor has incremented counter to: 3
90
- >>> Actor has incremented counter to: 4
91
- >>> Actor has incremented counter to: 5
92
- >>> Actor has incremented counter to: 6
93
- >>> Actor converts "foobar" to uppercase.
94
- #<CZTop::Message:0x7f81c55bdca0 frames=1 content_size=6 content=["FOOBAR"]>
95
- >>> Actor produces 5 messages.
96
- FOO 1/5
97
- FOO 2/5
98
- FOO 3/5
99
- FOO 4/5
100
- FOO 5/5
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'cztop'
3
-
4
- # create and bind socket
5
- socket = CZTop::Socket::REP.new("ipc:///tmp/req_rep_example")
6
- puts "<<< Socket bound to #{socket.last_endpoint.inspect}"
7
-
8
- # Simply echo every message, with every frame String#upcase'd.
9
- while msg = socket.receive
10
- puts "<<< #{msg.to_a.inspect}"
11
- socket << msg.to_a.map(&:upcase)
12
- end
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'cztop'
3
-
4
- # connect
5
- socket = CZTop::Socket::REQ.new("ipc:///tmp/req_rep_example")
6
- puts ">>> Socket connected."
7
-
8
- # simple string
9
- socket << "foobar"
10
- msg = socket.receive
11
- puts ">>> #{msg.to_a.inspect}"
12
-
13
- # multi frame message as array
14
- socket << %w[foo bar baz]
15
- msg = socket.receive
16
- puts ">>> #{msg.to_a.inspect}"
17
-
18
- # manually instantiating a Message
19
- msg = CZTop::Message.new("bla")
20
- msg << "another frame" # append a frame
21
- socket << msg
22
- msg = socket.receive
23
- puts ">>> #{msg.to_a.inspect}"
24
-
25
- ##
26
- # This will send 20 additional messages:
27
- #
28
- # ./req.rb 20
29
- #
30
- if ARGV.first
31
- ARGV.first.to_i.times do
32
- socket << ["fooooooooo", "baaaaaar"]
33
- puts ">>> " + socket.receive.to_a.inspect
34
- end
35
- end
@@ -1,2 +0,0 @@
1
- secret_keys/
2
- public_keys/
@@ -1,2 +0,0 @@
1
- README.md: README.gsl generate_keys.rb broker.rb client.rb start_broker.sh start_clients.sh
2
- gsl README
@@ -1,115 +0,0 @@
1
- .output "README.md"
2
- .template 1
3
- # Taxi System
4
-
5
- Suppose you're running a taxi company. You have a set of taxi drivers
6
- working for you. You'd like to connect them to your central server, so they're
7
- ready to get service requests from customers who'd like to get picked up by a
8
- taxi from some place X. As soon as a customer sends his service request, the
9
- central server will send the closest taxi nearby that's available to the
10
- customer.
11
-
12
- Of course you want the communication between the broker and the taxi drivers to
13
- be secure, meaning you want encryption and authentication.
14
-
15
- You also want ping-pong heartbeating, as you want to have confidence you can
16
- get in touch with your taxi drivers any time you want. And if a service
17
- request can't be delivered to a particular taxi driver, you wanna know
18
- immediately.
19
-
20
- This solution is implemented using CLIENT/SERVER sockets and the CURVE
21
- security mechanism.
22
-
23
- ## Broker
24
-
25
- Here's a possible implementation of the broker. What you'll have to provide
26
- are the environment variables `BROKER_ADDRESS` (the public TCP endpoint),
27
- `BROKER_CERT` (path to the broker's secret+public keys), and `CLIENT_CERTS`
28
- (directory to taxi drivers' certificates, public keys only).
29
-
30
- After the start, the broker will just start listening for the drivers (CLIENT
31
- sockets) to connect. After a driver has connected, authenticated, and sent its
32
- `HELLO` message, the broker answers with a `WELCOME` or `WELCOMEBACK` message,
33
- depending if the driver was connected before (it might have reconnected and
34
- been assigned a new routing ID).
35
-
36
- The broker will present you with a Pry shell. Right before starting the shell,
37
- there's a small usage information, but it's not very well visible due to Pry's
38
- noisy start. It's simple, though. Inside that shell, you can use the method
39
- `#send_command(driver, command)`. Example:
40
-
41
- ```
42
- pry> send_command("driver1", "foobar")
43
- ```
44
-
45
- Depending on whether the driver is connected, it'll send the message or report
46
- that it cannot do so.
47
-
48
- ```ruby
49
- .literal from "broker.rb"
50
- ```
51
-
52
- ## Client
53
-
54
- Here you have to provide the environment variables `BROKER_ADDRESS` (ditto),
55
- `BROKER_CERT` (public key only), `CLIENT_CERT` (taxi driver's certificate
56
- containing the secret+public keys).
57
-
58
- After connecting to the broker and completing the security handshake, the
59
- client sends a `HELLO` message, after which it immediately expects some answer
60
- from the broker (see above). After that, it just listens for messages (service
61
- requests) and prints them into the terminal.
62
-
63
- ```ruby
64
- .literal from "client.rb"
65
- ```
66
-
67
- ## How to run the example
68
-
69
- ### Generate broker's and drivers' keys
70
-
71
- Here's a simple script that'll create the broker's certificate and the taxi
72
- drivers' certificates. There are also public key only files so a minimum amount
73
- of information can be made available on one system, e.g. a taxi driver's system
74
- must not know the broker's secret key. Also, the broker doesn't necessarily
75
- need to know the clients' secret keys just to authenticate them.
76
-
77
- ```ruby
78
- .literal from "generate_keys.rb"
79
-
80
- ```
81
- Run it as follows:
82
-
83
- ```
84
- \./generate_keys.rb
85
- ```
86
-
87
- ### Start broker
88
-
89
- Run this:
90
-
91
- ```
92
- \./start_broker.sh
93
- ```
94
-
95
- which will execute the following script:
96
-
97
- ```sh
98
- .literal from "start_broker.sh"
99
- ```
100
-
101
- ### Start driver software instances
102
-
103
- Run this in another terminal:
104
-
105
- ```
106
- \./start_clients.sh
107
- ```
108
-
109
- which will execute the following script:
110
-
111
- ```sh
112
- .literal from "start_clients.sh"
113
- ```
114
-
115
- .endtemplate