Streamful

Check-in [297cac6152]
Login

Check-in [297cac6152]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Proved we can fetch and display a complete thread
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 297cac6152c60c537864b2584ecc3586b0e27660cd67cb038da721072c06fdc9
User & Date: scstarkey 2025-03-13 13:50:13
Context
2025-03-13
13:53
A few more comments check-in: a79cd2aea0 user: scstarkey tags: trunk
13:50
Proved we can fetch and display a complete thread check-in: 297cac6152 user: scstarkey tags: trunk
13:29
Fetch a bunch of messages by SHA (to see a whole thread, etc) check-in: 45ef5a3872 user: scstarkey tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/streamful/protocol.clj.

144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
        (agg/execute agg-system {:id msg-id, :m cmd})
        (str ok-response " " msg-id))

      (= :unauthorized result) unauthorized-response

      :else
      (do
        (log/warn "Failed to configure stream" result)
        failed-response))))

(defn-authd claim-server! [client-psk
                           stream-model
                           expected-claim-key
                           {{:strs [claim-key]} "m"}]








|







144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
        (agg/execute agg-system {:id msg-id, :m cmd})
        (str ok-response " " msg-id))

      (= :unauthorized result) unauthorized-response

      :else
      (do
        (log/warn "Failed to put to stream" result)
        failed-response))))

(defn-authd claim-server! [client-psk
                           stream-model
                           expected-claim-key
                           {{:strs [claim-key]} "m"}]

Changes to test/streamful/manual_testing.clj.

98
99
100
101
102
103
104
105
106
107
108
109
110

111
112
113
114












115
116
117
118
119

120
121
122
123
124
125
126
      c
      {:t "msg"
       :n "threads"
       :s tagg/thread-aggregate-selector-fn
       :a tagg/thread-aggregator-fn
       :c tagg/cleanup-thread-fn})))

(defn- show-thread [c sid msg-id]
  (as-> (client/get-messages c {:sid sid}) x
        (:response x)
        (x "messages")
        (map
          (fn [{:strs [id agg] {:strs [c k] {:strs [params]} "m"} "m" :as _raw}]

            {:id id, :cmd c, :params params, :agg agg, :k k
             ;;:raw raw
             }) x)
        (filter (fn [{:keys [id]}] (= msg-id id)) x)))













(comment
  (log/set-min-level! :error)

  (def c (client/new-client "localhost" 1100 server-pk 1000))

  (def c (client/new-client "localhost" 1100 "BAD" 1000))
  (def c2 (client/new-client "localhost" 1100 server-pk 1000))

  (def k (load-keys))

  (save-passphrase! (cr/passphrase))








|
<
|


|
>
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>





>







98
99
100
101
102
103
104
105

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
      c
      {:t "msg"
       :n "threads"
       :s tagg/thread-aggregate-selector-fn
       :a tagg/thread-aggregator-fn
       :c tagg/cleanup-thread-fn})))

(defn- recombinate [messages]

  (as-> (:response messages) x
        (x "messages")
        (map
          (fn [{:strs [id agg] {:strs [c k] {:strs [params sid]} "m"} "m"
                :as _raw}]
            {:sid sid, :id id, :cmd c, :params params, :agg agg, :k k
             ;;:raw _raw
             }) x)))

(defn- show-thread [c msg-id]
  (let [msg (-> (client/get-messages-by-sha c [msg-id]) recombinate first)
        msg-ids ((:agg msg) "thm")

        thread-messages
        (concat [msg]
                (->> msg-ids (client/get-messages-by-sha c) recombinate))]
    #_(clojure.pprint/pprint thread-messages)
    (->> thread-messages
         (map (fn [{:keys [sid k] {:strs [t]} :params}]
                {:sid sid, :from (subs k 0 8), :msg t}))
         clojure.pprint/print-table)))

(comment
  (log/set-min-level! :error)

  (def c (client/new-client "localhost" 1100 server-pk 1000))

  (def c (client/new-client "localhost" 1100 "BAD" 1000))
  (def c2 (client/new-client "localhost" 1100 server-pk 1000))

  (def k (load-keys))

  (save-passphrase! (cr/passphrase))

173
174
175
176
177
178
179
180








181
182
183
184
185










186
187
188
189
190
191
192
          (map
            (fn [{:strs [id] {:strs [c] {:strs [params]} "m"} "m"}]
              {:id id, :cmd c, :params params}) x)
          (filter (fn [{:keys [cmd]}] (= "put" cmd)) x)
          (first x)
          (:id x)))

  (show-thread c "root" msg-id1)









  (client/submit-message c {:sid "public"
                            :t "hello, to you!"
                            :rid msg-id1
                            :tid msg-id1})











  (do (as c (new-keys)) (client/get-messages c {:sid "root"}))
  ;=> {:response {"status" "stream not found"}}

  (client/is-open? c)

  (time (doseq [x (range 25)] (println (client/ping c (str "go: " x)))))







|
>
>
>
>
>
>
>
>





>
>
>
>
>
>
>
>
>
>







186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
          (map
            (fn [{:strs [id] {:strs [c] {:strs [params]} "m"} "m"}]
              {:id id, :cmd c, :params params}) x)
          (filter (fn [{:keys [cmd]}] (= "put" cmd)) x)
          (first x)
          (:id x)))

  (show-thread c msg-id1)

  ;->
  ;|     :sid |    :from |              :msg |
  ;|----------+----------+-------------------|
  ;|     root | v+aycFhS |     hello, world! |
  ;|   public | v+aycFhS |    hello, to you! |
  ;| personal | v+aycFhS |   how are things? |
  ;|   public | v+aycFhS | things are great! |

  (client/submit-message c {:sid "public"
                            :t "hello, to you!"
                            :rid msg-id1
                            :tid msg-id1})

  (client/submit-message c {:sid "personal"
                            :t "how are things?"
                            :rid "MMWF6M+lEBSXXVRdWMnyy1DIk4ydccFfD7GN6WVvuM0="
                            :tid msg-id1})

  (client/submit-message c {:sid "public"
                            :t "things are great!"
                            :rid "eoaJIufUEywUL3OEc0iilUsmoN/aKRw9MDdEcoUBGwM="
                            :tid msg-id1})

  (do (as c (new-keys)) (client/get-messages c {:sid "root"}))
  ;=> {:response {"status" "stream not found"}}

  (client/is-open? c)

  (time (doseq [x (range 25)] (println (client/ping c (str "go: " x)))))