::event-counter

This commit is contained in:
Robert C. Martin 2023-06-22 10:15:23 -05:00
parent bb291a5243
commit f6d02b2f50
2 changed files with 19 additions and 2 deletions

View File

@ -3,7 +3,8 @@
[more-speech.types.active-subscription :as subscription-type]
[more-speech.types.profile :as profile-type]
[more-speech.types.relay :as relay-type]
[more-speech.types.tab :as tab-type])
[more-speech.types.tab :as tab-type]
[more-speech.types.event-counter :as event-counter-type])
(:import (javax.swing JFrame)
(javax.swing.tree DefaultMutableTreeNode)))
@ -74,8 +75,8 @@
::node-map
::orphaned-replies
::event-history
::event-counter-type/event-counter
::event-counter
::back-count
::send-chan
::article-window

View File

@ -0,0 +1,16 @@
(ns more-speech.types.event-counter
(:require [clojure.spec.alpha :as s]))
(s/def ::relay-url #(re-matches #"ws+://[\w.-]+/?" %))
(s/def ::total int?)
(s/def ::dups int?)
(s/def ::kinds (s/map-of int? int?))
;Counts incoming events and sorts them by relay and kind. Also counts dups.
(s/def ::event-counter (s/and
(s/keys :opt-un [::total
::dups
::kinds])
(s/map-of (s/or :keyword #{:total :dups :kinds}
:url ::relay-url)
some?)))