qqq 0.1.1 → 0.1.1.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 901963455ef035a7b1055749513102b79fa568304c668038a585dcff606f73b8
4
- data.tar.gz: 7de4aa5267b50b0d62b8815237ad61e36111d0859a0f7379f5d83388dc03ebf8
3
+ metadata.gz: bb0807569101ac3a9dd5bcb582dbcaced669fd5b71d298b75edb3fa18652aae1
4
+ data.tar.gz: 484588c403f56496c7cfd884c60b47c1a7d72f36167bc4c5ad7693a8b52a150c
5
5
  SHA512:
6
- metadata.gz: f3739b7a3fcbc083cf1017e64c5fc0182e120afb6b6e9736c69bfd6f175497ecbb8a79971e749e689622367f3b77df12802ad088f22f259403ba2da6fea4cfc2
7
- data.tar.gz: 471fc79d97ac7583978b2582eaa4bb77366e58e9cd445abf750069f399ec308e7232a175f1aaeac8e482262f1efb949dc945797213906abcae847fc10d8e488b
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
- * Version 0.1.0 - Milestone I
3
+ "Do one thing well"
3
4
 
4
- "Better than puts"
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
- - [ ] simplify dashboard
16
- - [X] create rudimentary uh... dashboard/orchestration
17
- - [X] Tighten e2e.sh test.
32
+ - [X] Create rudimentary uh... dashboard/orchestration
33
+ - [X] Create e2e.sh
18
34
 
19
- ** 0.1.1
35
+ * Roadmap
20
36
 
21
- table stakes
22
- - [ ] some sort of supervisor around cli, etc. e.g. api send dies if server not up yet. should hang out and retry
23
- - [ ] update documentation
24
- - [ ] general presentation polish
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
- - [ ] a way to specifiy redis config (my qqq's in tests are getting lost to a fake redis)
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
- dev
50
- - [ ] some sort of handshake system for handling processes
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
- * Beyond
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
- - consider other options?
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qqq (0.1.1)
4
+ qqq (0.1.1.1)
5
5
  activerecord
6
6
  faraday
7
7
  json
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 :tail
5
+ default_task "tail"
7
6
 
8
- desc :tail, "Tails the qqq log"
7
+ desc "tail", "Tails the qqq log"
9
8
  def tail
10
- QQQ.subscribe do |event|
11
- puts event.message
9
+ qqq.subscribe do |event|
10
+ puts event.for_humans
12
11
  end
13
12
  end
14
13
 
15
- desc :payload, "For now- separate tail"
16
- def payload
17
- QQQ.subscribe do |event|
18
- puts event.to_s
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 :mark, "Marks the log"
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("ECHO: #{messages.join(" ")}")
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, "Publishes the version number"
33
+ desc :version, "Logs the version number"
41
34
  def version
42
- puts "QQQ Version #{QQQ::VERSION}"
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.from(json_string:)
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
@@ -1,6 +1,6 @@
1
1
  module QQQ
2
2
  module Keys
3
- MESSAGES_CHANNEL_KEY = "qqq::messages_channel"
4
- EVENT_CHANNEL_KEY = "qqq::payload_channel"
3
+ SYSTEM_CHANNEL_KEY = "qqq::channel::system"
4
+ EVENT_CHANNEL_KEY = "qqq::channel::event"
5
5
  end
6
- end
6
+ end
data/lib/qqq/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module QQQ
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.1.1"
3
3
  end
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/event'
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
- # message = "hello world"
17
- def self.qqq(message)
18
- publish(message)
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 self.publish(message)
22
- uuid = UUIDTools::UUID.random_create().to_s
23
- timestamp = Time.now
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
- message_for_humans = "[#{uuid}] [#{timestamp}] #{message}"
26
- redis.publish(Keys::MESSAGES_CHANNEL_KEY, message_for_humans.to_json)
30
+ module QQQ
31
+ class Error < StandardError; end
27
32
 
28
- event = Event.new(uuid: uuid, message: message, recorded_at: timestamp)
29
- redis.publish(Keys::EVENT_CHANNEL_KEY, event.to_json)
30
- end
33
+ #
34
+ # Developer log channels
35
+ #
36
+ class Developer
31
37
 
32
- def self.subscribe &block
33
- redis.subscribe Keys::EVENT_CHANNEL_KEY do |on|
34
- puts "Connected..."
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
- on.message do |channel, event_json_string|
37
- event = Event.from(json_string: event_json_string)
38
- block.call(event)
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
- private
61
+ private
44
62
 
45
- def self.redis
46
- puts "wha hoo"
47
- if defined?(FakeRedis) && FakeRedis.enabled?
48
- FakeRedis.disable
49
- @redis ||= Redis.new
50
- FakeRedis.enable
51
- else
52
- @redis ||= Redis.new
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-24 00:00:00.000000000 Z
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/event.rb
206
+ - lib/qqq/events.rb
207
207
  - lib/qqq/keys.rb
208
208
  - lib/qqq/version.rb
209
209
  - qqq.gemspec