qqq 0.1.1 → 0.1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.org +128 -27
- data/Gemfile.lock +1 -1
- data/lib/qqq/api.rb +9 -0
- data/lib/qqq/cli.rb +19 -31
- data/lib/qqq/{event.rb → events.rb} +13 -3
- data/lib/qqq/keys.rb +3 -3
- data/lib/qqq/version.rb +1 -1
- data/lib/qqq.rb +51 -32
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb0807569101ac3a9dd5bcb582dbcaced669fd5b71d298b75edb3fa18652aae1
|
4
|
+
data.tar.gz: 484588c403f56496c7cfd884c60b47c1a7d72f36167bc4c5ad7693a8b52a150c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e6c7a27bfd72b2b42808136f4cd026d00f88a702286e0a9ace78ee9d201a8a7f61e8f4773f716e52d22dd0d9d947c7bbf2bc8c7616b81fa44fdbc0c3ccca91a
|
7
|
+
data.tar.gz: 562a4bff7546705caf92a099b66e36c3e241479a633c2d799cd35f82af41ac73370dd702e30f3002629edc35633f17c2cbe181e999c6c4b668989a6f543dc1ac
|
data/CHANGELOG.org
CHANGED
@@ -1,59 +1,160 @@
|
|
1
|
+
* Upcoming 0.2.0 - Woodworking
|
1
2
|
|
2
|
-
|
3
|
+
"Do one thing well"
|
3
4
|
|
4
|
-
|
5
|
+
Slim down all the extras. Focus on print debugging from anywhere in ruby.
|
6
|
+
|
7
|
+
** 0.1.2
|
8
|
+
|
9
|
+
- [X] Simplify dashboard, easier to read
|
10
|
+
- [X] remove send... for now.
|
11
|
+
- [X] remove payload command for only tail
|
12
|
+
- [X] mark command can optionally repeat
|
13
|
+
|
14
|
+
** 0.1.1
|
15
|
+
|
16
|
+
- [X] Hack around fakeredis to get redis connection, if enabled
|
17
|
+
- [X] Remove messages in favor of richer Event structure
|
18
|
+
|
19
|
+
* DONE 0.1.0 - A Thing
|
20
|
+
|
21
|
+
"It's doing /something/"
|
5
22
|
|
6
23
|
features
|
7
|
-
- [X] recorded timestamp and uuid recorded in db
|
8
|
-
- [X] record in a database
|
24
|
+
- [X] recorded timestamp and uuid recorded in db through app
|
25
|
+
- [X] record message in a database
|
9
26
|
- [X] send to an api
|
10
27
|
- [X] timestamps
|
11
28
|
- [X] send message from command line
|
12
29
|
- [X] tail and mark from command line
|
13
30
|
|
14
31
|
dev
|
15
|
-
- [
|
16
|
-
- [X]
|
17
|
-
- [X] Tighten e2e.sh test.
|
32
|
+
- [X] Create rudimentary uh... dashboard/orchestration
|
33
|
+
- [X] Create e2e.sh
|
18
34
|
|
19
|
-
|
35
|
+
* Roadmap
|
20
36
|
|
21
|
-
|
22
|
-
- [ ]
|
23
|
-
- [ ]
|
24
|
-
- [ ]
|
37
|
+
** Table stakes / cleanup
|
38
|
+
- [ ] Add enough documentation to hello, world (and understand what qqq is)
|
39
|
+
- [ ] get someone else to install it, use it
|
40
|
+
- [ ] Supervisor around cli, etc. e.g. api send dies if server not up yet
|
41
|
+
- [ ] Cut out redis for ruby pubsub? generate servers for every lang..? just make them..? https://blog.appsignal.com/2018/08/28/push-and-pubsub-in-ruby.html
|
25
42
|
- [ ] more tests? CI?
|
43
|
+
- [ ] Remove payload/messages dichotomy
|
26
44
|
|
27
|
-
features
|
28
|
-
- [ ]
|
29
|
-
|
30
|
-
* Milestone II
|
31
|
-
|
32
|
-
features
|
45
|
+
** user features
|
46
|
+
- [ ] file worker (append to /tmp/qqq)
|
47
|
+
- [ ] a way to specifiy redis config
|
33
48
|
- [ ] did not run (no wondering if line didn't run)... possible?
|
34
49
|
- [ ] increments if run multiple times..
|
35
50
|
- [ ] start / stop 'marks'
|
36
51
|
- [ ] some recent history (last 100?) when I start tailing
|
37
52
|
- [ ] q, qq, qqq levels
|
38
|
-
- [ ] file worker (append to /tmp/qqq)
|
39
53
|
- [ ] plugin arch for worker
|
40
54
|
- [ ] updated development documentation
|
41
55
|
- [ ] api key to follow me around (~/.qqq.conf or whatever)
|
42
56
|
- [ ] updating webapp (websockets)
|
43
57
|
- [ ] handles complex object printing
|
44
|
-
- [ ] rich data
|
58
|
+
- [ ] accept payloads, rich data, rich data
|
45
59
|
- [ ] metaprogramming / reflection
|
46
60
|
- [ ] config panel to turn on/off 'q steams'
|
47
61
|
|
48
|
-
|
49
|
-
|
50
|
-
- [ ]
|
62
|
+
** dev
|
63
|
+
- [ ] how can i test this whole system
|
64
|
+
- [ ] system log channel,
|
65
|
+
- [ ] perhaps.. handshake system for handling processes, testing?
|
51
66
|
- [ ] local gem dev - de-req rake install loop
|
52
67
|
- [ ] split out configuration (yaml?) for 'service' interaction
|
53
|
-
- [ ] split the development panel / user panel
|
68
|
+
- [ ] split the development panel / user panel
|
54
69
|
|
55
|
-
|
70
|
+
** brewing ideas
|
56
71
|
|
72
|
+
- get off redis... https://faye.jcoglan.com/ruby/clients.html
|
57
73
|
- move to a ruby only actor model? (https://github.com/ntl/actor)
|
58
|
-
-
|
59
|
-
- electron app for dashboard? get away from shell stuff
|
74
|
+
- other langs, javascript?
|
75
|
+
- electron app for dashboard? get away from shell stuff...
|
76
|
+
|
77
|
+
restreaming
|
78
|
+
- qqq.restream(:my_event) do |event|
|
79
|
+
...
|
80
|
+
end
|
81
|
+
|
82
|
+
- log to the standard log with a link to the specific log
|
83
|
+
|
84
|
+
check out https://github.com/janlelis/debugging
|
85
|
+
|
86
|
+
*** Writing a program to generate the apis...
|
87
|
+
|
88
|
+
Could I write some sort of program that could.. create these clients?
|
89
|
+
|
90
|
+
#+begin_src lisp
|
91
|
+
(namespace :QQQ :CLI
|
92
|
+
(define-cli
|
93
|
+
(define-task "tail"
|
94
|
+
(qqq/subscribe (key message-channel) print-event-to-screen)))
|
95
|
+
|
96
|
+
(define-function print-event-to-screen (event)
|
97
|
+
(system-output-command
|
98
|
+
(brackets (:timestamp event))
|
99
|
+
(space)
|
100
|
+
(brackets (:uuid event))
|
101
|
+
(space)
|
102
|
+
(brackets (:message event))
|
103
|
+
(newline))))
|
104
|
+
|
105
|
+
(namespace
|
106
|
+
:QQQ :API
|
107
|
+
(define-function :publish (message)
|
108
|
+
(redis :publish (key event-channel)
|
109
|
+
(marshall-to-json (create-event
|
110
|
+
(create-uuid
|
111
|
+
create-timestamp
|
112
|
+
message)))))
|
113
|
+
|
114
|
+
(namespace
|
115
|
+
:QQQ :API
|
116
|
+
(define-function :subscribe (function_or_callable)
|
117
|
+
(redis :subscribe (key event-channel)
|
118
|
+
(lambda (event) (call function_or_callable event)))))
|
119
|
+
#+end_src
|
120
|
+
|
121
|
+
|
122
|
+
Could potentially use org-mode/tangle to do multi-lang well
|
123
|
+
|
124
|
+
(After qqq, do developer user interviews screen share to find real patterns...)
|
125
|
+
|
126
|
+
Under heading * Ruby ** Define Module
|
127
|
+
|
128
|
+
#+value: module-name
|
129
|
+
#+value: content
|
130
|
+
#+begin_src ruby
|
131
|
+
defmodule #{module-name}
|
132
|
+
#{content}
|
133
|
+
end
|
134
|
+
#+end_src
|
135
|
+
|
136
|
+
I bet that could done reasonably in ruby...
|
137
|
+
|
138
|
+
|
139
|
+
#+begin_src ruby
|
140
|
+
class Generator
|
141
|
+
attr_reader :lang
|
142
|
+
def define_namespace (name, &content_block)
|
143
|
+
#render :erb, "path/to/_module.erb", name, content_block.render
|
144
|
+
<<-END
|
145
|
+
defmodule #{name}
|
146
|
+
#{content_block.render}
|
147
|
+
end
|
148
|
+
END
|
149
|
+
end
|
150
|
+
|
151
|
+
|
152
|
+
define_namespace(:QQQ) do
|
153
|
+
define_module(:CLI) do
|
154
|
+
define_func(:echo, :argument_vector) do |messages|
|
155
|
+
Generated::Formatters::ForHumans.format(messages)
|
156
|
+
Generated::Library::QQQ::publish
|
157
|
+
end
|
158
|
+
end
|
159
|
+
end
|
160
|
+
#+end_src
|
data/Gemfile.lock
CHANGED
data/lib/qqq/api.rb
CHANGED
@@ -2,6 +2,15 @@ require 'faraday'
|
|
2
2
|
|
3
3
|
module QQQ
|
4
4
|
module API
|
5
|
+
|
6
|
+
# desc :send, "Sends message to a remote server"
|
7
|
+
# def send
|
8
|
+
# QQQ.subscribe do |event|
|
9
|
+
# puts "Remotely publishing: #{event.message}"
|
10
|
+
# API.publish(event)
|
11
|
+
# end
|
12
|
+
# end
|
13
|
+
|
5
14
|
def self.publish(event)
|
6
15
|
conn = Faraday.new(:url => "http://localhost:3600")
|
7
16
|
resp = conn.post '/events', { :event => event.as_json }
|
data/lib/qqq/cli.rb
CHANGED
@@ -1,52 +1,40 @@
|
|
1
1
|
require 'thor'
|
2
|
-
require 'json'
|
3
2
|
|
4
3
|
module QQQ
|
5
4
|
class CLI < Thor
|
6
|
-
default_task
|
5
|
+
default_task "tail"
|
7
6
|
|
8
|
-
desc
|
7
|
+
desc "tail", "Tails the qqq log"
|
9
8
|
def tail
|
10
|
-
|
11
|
-
puts event.
|
9
|
+
qqq.subscribe do |event|
|
10
|
+
puts event.for_humans
|
12
11
|
end
|
13
12
|
end
|
14
13
|
|
15
|
-
desc
|
16
|
-
def
|
17
|
-
|
18
|
-
|
14
|
+
desc "mark [repeat_interval]", "Marks the log (optionally every X seconds)"
|
15
|
+
def mark(repeat_interval)
|
16
|
+
repeat_interval = repeat_interval.to_i rescue 0
|
17
|
+
loop do
|
18
|
+
qqq.mark
|
19
|
+
|
20
|
+
if repeat_interval > 0
|
21
|
+
sleep repeat_interval
|
22
|
+
else
|
23
|
+
break
|
24
|
+
end
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
22
|
-
desc
|
23
|
-
def mark
|
24
|
-
QQQ.publish("MARK: --MARK--")
|
25
|
-
end
|
26
|
-
|
27
|
-
desc "echo [messages]", "Simple echo"
|
28
|
+
desc "echo [messages]", "Log a message"
|
28
29
|
def echo(*messages)
|
29
|
-
QQQ.publish("
|
30
|
-
end
|
31
|
-
|
32
|
-
desc :send, "Sends message to a remote server"
|
33
|
-
def send
|
34
|
-
QQQ.subscribe do |event|
|
35
|
-
puts "Remotely publishing: #{event.message}"
|
36
|
-
API.publish(event)
|
37
|
-
end
|
30
|
+
QQQ.publish("#{messages.join(" ")}")
|
38
31
|
end
|
39
32
|
|
40
|
-
desc :version, "
|
33
|
+
desc :version, "Logs the version number"
|
41
34
|
def version
|
42
|
-
puts "QQQ
|
35
|
+
puts "QQQ version: #{QQQ::VERSION}"
|
43
36
|
QQQ.publish(QQQ::VERSION)
|
44
37
|
end
|
45
|
-
|
46
|
-
# desc :server, "Starts server to receive message"
|
47
|
-
# def server
|
48
|
-
# Sinatra....how?
|
49
|
-
# end
|
50
38
|
end
|
51
39
|
end
|
52
40
|
|
@@ -3,16 +3,25 @@ module QQQ
|
|
3
3
|
|
4
4
|
attr_reader :uuid, :message, :recorded_at
|
5
5
|
|
6
|
-
def self.
|
6
|
+
def self.from_message(message)
|
7
|
+
timestamp = Time.now
|
8
|
+
uuid = UUIDTools::UUID.random_create().to_s
|
9
|
+
Event.new(uuid: uuid, message: message, recorded_at: timestamp)
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.from_json_string(json_string)
|
7
13
|
payload = JSON.parse json_string
|
8
|
-
puts payload
|
9
14
|
Event.new(uuid: payload["uuid"], message: payload["message"], recorded_at: payload["recorded_at"])
|
10
15
|
end
|
11
16
|
|
12
17
|
def initialize(uuid:, message:, recorded_at:)
|
13
18
|
@uuid = uuid
|
14
|
-
@message = message
|
15
19
|
@recorded_at = recorded_at
|
20
|
+
@message = message
|
21
|
+
end
|
22
|
+
|
23
|
+
def for_humans
|
24
|
+
"[#{@uuid}] [#{@recorded_at}] #{@message}"
|
16
25
|
end
|
17
26
|
|
18
27
|
def as_json(options={})
|
@@ -27,4 +36,5 @@ module QQQ
|
|
27
36
|
end
|
28
37
|
|
29
38
|
end
|
39
|
+
|
30
40
|
end
|
data/lib/qqq/keys.rb
CHANGED
data/lib/qqq/version.rb
CHANGED
data/lib/qqq.rb
CHANGED
@@ -1,57 +1,76 @@
|
|
1
|
+
# Gems
|
1
2
|
require 'redis'
|
2
3
|
require 'json'
|
4
|
+
require 'uuidtools'
|
3
5
|
|
4
6
|
# Lib
|
5
|
-
require 'qqq/
|
7
|
+
require 'qqq/events'
|
6
8
|
require 'qqq/api'
|
7
9
|
require 'qqq/cli'
|
8
10
|
require 'qqq/keys'
|
9
11
|
require 'qqq/version'
|
10
12
|
|
11
|
-
require 'uuidtools'
|
12
13
|
|
13
|
-
module QQQ
|
14
|
-
class Error < StandardError; end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
15
|
+
module Kernel
|
16
|
+
private
|
17
|
+
def q(message=nil)
|
18
|
+
@qqq_developer ||= QQQ::Developer.new
|
19
|
+
message ? @qqq_developer.publish(message) : @qqq_developer.mark
|
20
|
+
@qqq_developer
|
19
21
|
end
|
20
22
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
23
|
+
def qqq(message=nil)
|
24
|
+
@qqq_developer ||= QQQ::Developer.new
|
25
|
+
message ? @qqq_developer.publish(message) : @qqq_developer.mark
|
26
|
+
@qqq_developer
|
27
|
+
end
|
28
|
+
end
|
24
29
|
|
25
|
-
|
26
|
-
|
30
|
+
module QQQ
|
31
|
+
class Error < StandardError; end
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
33
|
+
#
|
34
|
+
# Developer log channels
|
35
|
+
#
|
36
|
+
class Developer
|
31
37
|
|
32
|
-
|
33
|
-
|
34
|
-
|
38
|
+
def initialize
|
39
|
+
@mark_counter = 0
|
40
|
+
end
|
41
|
+
|
42
|
+
def mark
|
43
|
+
@mark_counter += 1
|
44
|
+
publish("MARK: --MARK-- (#{@mark_counter})")
|
45
|
+
end
|
46
|
+
|
47
|
+
def publish(message)
|
48
|
+
event = Event.from_message(message)
|
49
|
+
redis.publish(Keys::EVENT_CHANNEL_KEY, event.to_json)
|
50
|
+
end
|
35
51
|
|
36
|
-
|
37
|
-
|
38
|
-
|
52
|
+
def subscribe &block
|
53
|
+
redis.subscribe Keys::EVENT_CHANNEL_KEY do |on|
|
54
|
+
on.message do |channel, event_json_string|
|
55
|
+
event = Event.from_json_string(event_json_string)
|
56
|
+
block.call(event)
|
57
|
+
end
|
39
58
|
end
|
40
59
|
end
|
41
|
-
end
|
42
60
|
|
43
|
-
|
61
|
+
private
|
44
62
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
63
|
+
def redis
|
64
|
+
if defined?(FakeRedis) && FakeRedis.enabled?
|
65
|
+
FakeRedis.disable
|
66
|
+
@redis ||= Redis.new
|
67
|
+
FakeRedis.enable
|
68
|
+
else
|
69
|
+
@redis ||= Redis.new
|
70
|
+
end
|
71
|
+
|
72
|
+
@redis
|
53
73
|
end
|
54
74
|
end
|
55
|
-
|
56
75
|
end
|
57
76
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qqq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1
|
4
|
+
version: 0.1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Skulski
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-05-
|
11
|
+
date: 2019-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis
|
@@ -203,7 +203,7 @@ files:
|
|
203
203
|
- lib/qqq.rb
|
204
204
|
- lib/qqq/api.rb
|
205
205
|
- lib/qqq/cli.rb
|
206
|
-
- lib/qqq/
|
206
|
+
- lib/qqq/events.rb
|
207
207
|
- lib/qqq/keys.rb
|
208
208
|
- lib/qqq/version.rb
|
209
209
|
- qqq.gemspec
|