tupelo 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/tspy +40 -0
- data/bin/tup +163 -0
- data/lib/tupelo/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85aab8de585bbe205e0d0646ed13c3c59e6fc364
|
4
|
+
data.tar.gz: d43dd9d8e6dfe6c6b76380d25715cf25d5ea442f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bed46e18b23568aa1a0cb29d4900a279cdc202c7deb8bd43c3c77e69b6de7741ddcf333a929723a1d5cf7e5e913be17ead8af24db0c57783e3faf8c2e80dfed
|
7
|
+
data.tar.gz: 5c858ea811be67a255f09c9fae784a62f7afc993c41c1188280fda67554f8b8884b9928d96dba5b5153b63425ff08495044a1eae2c2a48e86bc4b1c43d4d9bad
|
data/bin/tspy
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if ARGV.delete("-h") or ARGV.delete("--help")
|
4
|
+
puts <<-END
|
5
|
+
Usage:
|
6
|
+
#$0 servers_file
|
7
|
+
|
8
|
+
Connect to the tuplespace specified by the servers_file and
|
9
|
+
use the notification api to print out all events.
|
10
|
+
|
11
|
+
For example, you can start a tup with
|
12
|
+
|
13
|
+
tup svr
|
14
|
+
|
15
|
+
and then in another terminal
|
16
|
+
|
17
|
+
tspy svr
|
18
|
+
|
19
|
+
Options:
|
20
|
+
|
21
|
+
--debug set the log level
|
22
|
+
--info
|
23
|
+
--warn <-- default
|
24
|
+
--error
|
25
|
+
--fatal
|
26
|
+
END
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'tupelo/app'
|
31
|
+
|
32
|
+
Tupelo.application do |app|
|
33
|
+
app.local do |client|
|
34
|
+
note = client.notifier
|
35
|
+
client.log "%10s %10s %10s %s" % %w{ status tick client operation }
|
36
|
+
loop do
|
37
|
+
client.log "%10s %10d %10d %p" % note.wait
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/bin/tup
ADDED
@@ -0,0 +1,163 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
if ARGV.delete("-h") or ARGV.delete("--help")
|
4
|
+
puts <<-END
|
5
|
+
Usage:
|
6
|
+
#$0
|
7
|
+
|
8
|
+
#$0 servers_file
|
9
|
+
#$0 servers_file <script...
|
10
|
+
|
11
|
+
#$0 servers_file unix [path]
|
12
|
+
#$0 servers_file tcp [host [port]]]
|
13
|
+
|
14
|
+
The first form starts a tuplespace server as a child process. Then it
|
15
|
+
enters an interactive session in which the current object is the proxy to
|
16
|
+
that tuplespace. This form is useful for an isolated tuplespace for
|
17
|
+
simple experiments.
|
18
|
+
|
19
|
+
The second form tries to open the servers_file. If it cannot, then as in the
|
20
|
+
first form, it starts a tuplespace server child process and writes its
|
21
|
+
address to servers_file. If it can open the servers_file, then it simply
|
22
|
+
connects to the referenced tuplespace server. In either case, as in the
|
23
|
+
first form, an interactive session starts. This form (in its two variants)
|
24
|
+
is useful for starting two sessions operating on the same tuplespace.
|
25
|
+
|
26
|
+
The third form is like the second form, but executes the input instead of
|
27
|
+
starting an interactive session. Output is like irb output, with input lines
|
28
|
+
alternating with their output. This is useful for generating human-readable
|
29
|
+
transcripts.
|
30
|
+
|
31
|
+
The fourth and fifth forms are like the previous, but can be used to expose
|
32
|
+
the server on more or less public sockets with specified addresses. In the
|
33
|
+
tcp case, the servers_file can be copied to other hosts and used with tup
|
34
|
+
to connect to the servers (adjust the host references as needed). The
|
35
|
+
default for unix is, as in the first three forms, a path in a tmpdir. The
|
36
|
+
default for tcp is localhost with port 0, and hence a dynamically chosen
|
37
|
+
port. These forms are only for starting a new server; connecting to an
|
38
|
+
existing server uses the simpler form "#$0 servers_file".
|
39
|
+
|
40
|
+
Options:
|
41
|
+
|
42
|
+
--debug set the log level
|
43
|
+
--info
|
44
|
+
--warn <-- default
|
45
|
+
--error
|
46
|
+
--fatal
|
47
|
+
|
48
|
+
-v verbose mode (include time and pid in log messages)
|
49
|
+
|
50
|
+
--pubsub publish/subscribe mode; does not keep local tuple store:
|
51
|
+
|
52
|
+
* read only works in blocking mode (waiting for new tuple)
|
53
|
+
* write and pulse work normally
|
54
|
+
* take does not work
|
55
|
+
|
56
|
+
--marshal use specified library to serialize objects
|
57
|
+
--yaml
|
58
|
+
--json
|
59
|
+
--msgpack <-- default
|
60
|
+
|
61
|
+
END
|
62
|
+
exit
|
63
|
+
end
|
64
|
+
|
65
|
+
require 'easy-serve'
|
66
|
+
|
67
|
+
log_level = case
|
68
|
+
when ARGV.delete("--debug"); Logger::DEBUG
|
69
|
+
when ARGV.delete("--info"); Logger::INFO
|
70
|
+
when ARGV.delete("--warn"); Logger::WARN
|
71
|
+
when ARGV.delete("--error"); Logger::ERROR
|
72
|
+
when ARGV.delete("--fatal"); Logger::FATAL
|
73
|
+
else Logger::WARN
|
74
|
+
end
|
75
|
+
verbose = ARGV.delete("-v")
|
76
|
+
pubsub = ARGV.delete("--pubsub")
|
77
|
+
|
78
|
+
blob_type = nil
|
79
|
+
%w{--marshal --yaml --json --msgpack}.each do |switch|
|
80
|
+
s = ARGV.delete(switch) and
|
81
|
+
blob_type ||= s.delete("--")
|
82
|
+
end
|
83
|
+
|
84
|
+
ez_opts = {
|
85
|
+
servers_file: ARGV.shift,
|
86
|
+
interactive: $stdin.isatty
|
87
|
+
}
|
88
|
+
|
89
|
+
addr = ARGV.shift(3)
|
90
|
+
|
91
|
+
EasyServe.start ez_opts do |ez|
|
92
|
+
log = ez.log
|
93
|
+
log.level = log_level
|
94
|
+
log.formatter = nil if verbose
|
95
|
+
log.progname = File.basename($0)
|
96
|
+
|
97
|
+
ez.start_servers do
|
98
|
+
arc_to_seq_sock, seq_to_arc_sock = UNIXSocket.pair
|
99
|
+
arc_to_cseq_sock, cseq_to_arc_sock = UNIXSocket.pair
|
100
|
+
|
101
|
+
ez.server :seqd, *addr do |svr|
|
102
|
+
require 'funl/message-sequencer'
|
103
|
+
seq_opts = {}
|
104
|
+
seq_opts[:blob_type] = blob_type if blob_type
|
105
|
+
seq = Funl::MessageSequencer.new svr, seq_to_arc_sock, log: log,
|
106
|
+
**seq_opts
|
107
|
+
seq.start ## thwait? or can easy-serve do that?
|
108
|
+
end
|
109
|
+
|
110
|
+
ez.server :cseqd, *addr do |svr|
|
111
|
+
require 'funl/client-sequencer'
|
112
|
+
cseq = Funl::ClientSequencer.new svr, cseq_to_arc_sock, log: log
|
113
|
+
cseq.start
|
114
|
+
end
|
115
|
+
|
116
|
+
ez.server :arcd, *addr do |svr|
|
117
|
+
require 'tupelo/archiver'
|
118
|
+
arc = Tupelo::Archiver.new svr, seq: arc_to_seq_sock,
|
119
|
+
cseq: arc_to_cseq_sock, log: log
|
120
|
+
arc.start
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
ez.local :seqd, :cseqd, :arcd do |seqd, cseqd, arcd|
|
125
|
+
log.progname = "client <starting in #{log.progname}>"
|
126
|
+
|
127
|
+
require 'tupelo/client'
|
128
|
+
class TupClient < Tupelo::Client
|
129
|
+
alias w write_wait
|
130
|
+
alias pl pulse_wait
|
131
|
+
alias t take
|
132
|
+
alias r read_wait
|
133
|
+
alias ra read_all
|
134
|
+
alias tr transaction
|
135
|
+
CMD_ALIASES = %w{ w pl t r ra tr }
|
136
|
+
private *CMD_ALIASES
|
137
|
+
end
|
138
|
+
|
139
|
+
client_opts = {seq: seqd, cseq: cseqd, log: log}
|
140
|
+
if pubsub
|
141
|
+
client_opts[:arc] = nil
|
142
|
+
client_opts[:tuplespace] = TupClient::NullTuplespace
|
143
|
+
else
|
144
|
+
client_opts[:arc] = arcd
|
145
|
+
end
|
146
|
+
|
147
|
+
client = TupClient.new client_opts
|
148
|
+
client.start do
|
149
|
+
log.progname = "client #{client.client_id}"
|
150
|
+
end
|
151
|
+
log.info {
|
152
|
+
"cpu time: %.2fs" % Process.times.inject {|s,x|s+x}
|
153
|
+
}
|
154
|
+
log.info {
|
155
|
+
"starting shell. Commands: #{TupClient::CMD_ALIASES.join(", ")}"
|
156
|
+
}
|
157
|
+
|
158
|
+
require 'irb-shell'
|
159
|
+
IRB.start_session(client)
|
160
|
+
|
161
|
+
client.stop
|
162
|
+
end
|
163
|
+
end
|
data/lib/tupelo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tupelo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joel VanderWerf
|
@@ -26,7 +26,9 @@ dependencies:
|
|
26
26
|
version: '0'
|
27
27
|
description: Distributed tuplespace.
|
28
28
|
email: vjoel@users.sourceforge.net
|
29
|
-
executables:
|
29
|
+
executables:
|
30
|
+
- tup
|
31
|
+
- tspy
|
30
32
|
extensions: []
|
31
33
|
extra_rdoc_files:
|
32
34
|
- README.md
|
@@ -96,6 +98,8 @@ files:
|
|
96
98
|
- test/unit/test-mock-seq.rb
|
97
99
|
- test/unit/test-mock-queue.rb
|
98
100
|
- test/stress/concurrent-transactions.rb
|
101
|
+
- bin/tup
|
102
|
+
- bin/tspy
|
99
103
|
homepage: https://github.com/vjoel/tupelo
|
100
104
|
licenses:
|
101
105
|
- BSD
|