Skip to content

Instantly share code, notes, and snippets.

View MichaelDrogalis's full-sized avatar

Michael Drogalis MichaelDrogalis

  • Confluent
  • Seattle, WA
View GitHub Profile
(require '[metamorphic.api :as m]
'[metamorphic.runtime :as rt])
;; Find a single "a"
(let [runtime (-> (m/new-pattern-sequence "just an a")
(m/begin "a" (fn [event & _] (= event "a")))
(rt/initialize-runtime))
events ["b" "c" "a" "d" "q" "a" "r"]]
(:matches (reduce rt/evaluate-event runtime events)))
(def service
(-> (new-service)
(input-topic "events")
(string-starts-with? [:context :url] "https://pyroclast.io")
(f/= :event :page-view)
(parse-datetime :timestamp "YYY-MM-dd'T'HH:mm:ss.SSSZ")
(aggregate-together
[{:name "hourly-page-views"
:aggregate (a/count (fixed-windows-of 1 :hour :timestamp))}]
:user-id)))
{ "id": 1, "name": "John" },
{ "id": 2, "name": "Bill" },
{ "id": 3, "name": "Sally" }
(s/def :flow/predicate
(s/or :and (s/cat :op (partial = :and) :exprs (s/+ :flow/predicate))
:or (s/cat :op (partial = :or) :exprs (s/+ :flow/predicate))
:not (s/cat :op (partial = :not) :exprs (s/cat :pred :flow/predicate))
:fn keyword?
:fn-and-args (s/cat :fn (λ [x]
(and (keyword? x)
(not (some #{x} #{:and :or :not}))))
:args (s/* keyword?))))
{"model":{"mapping":{"readyVMs":[],"onlineNodes":{"0":{"sleepingVMs":[],"runningVMs":[15,14,12,10,9,8,5]},"1":{"sleepingVMs":[],"runningVMs":[18,17,16,13,11,4,0]},"2":{"sleepingVMs":[],"runningVMs":[7,6]},"3":{"sleepingVMs":[],"runningVMs":[3,2,1]},"4":{"sleepingVMs":[],"runningVMs":[]}},"offlineNodes":[]},"attributes":{"nodes":{},"vms":{}},"views":[]},"constraints":[{"amount":7,"nodes":[0],"continuous":false,"id":"runningCapacity"},{"amount":6,"nodes":[1],"continuous":false,"id":"runningCapacity"},{"amount":3,"nodes":[2],"continuous":false,"id":"runningCapacity"},{"amount":2,"nodes":[3],"continuous":false,"id":"runningCapacity"},{"continuous":false,"parts":[[4,2,3,0,1]],"id":"among","vms":[0]},{"continuous":false,"parts":[[4,2,3,0,1]],"id":"among","vms":[1]},{"continuous":false,"parts":[[4,2,3,0,1]],"id":"among","vms":[2]},{"continuous":false,"parts":[[4,2,3,0,1]],"id":"among","vms":[3]},{"continuous":false,"parts":[[4,2,3,0,1]],"id":"among","vms":[4]},{"continuous":false,"parts":[[4,2,3,0,1]],"id":"among","
(s/def ::a integer?)
(s/def ::b string?)
(clojure.pprint/pprint (s/explain-data (s/keys :req [::a ::b]) {::a "foo" ::b "bar"}))
;; =>
;; {:clojure.spec/problems
;; {[:empathy.api/a]
;; {:pred integer?,
;; :val "foo",
function f (x) {
return function g(y) {
return x + y;
}
}
h = f(42)
h(58) // => 100
Host onyx-kafka
HostName github.com
User git
IdentityFile /home/ubuntu/.ssh/id_onyx-kafka
IdentitiesOnly yes
Host onyx-kafka-0.8
HostName github.com
User git
IdentityFile /home/ubuntu/.ssh/id_onyx-kafka-0.8
IdentitiesOnly yes

Replica Query Server Endpoints

[:get] /job/flow-conditions

Given a job id, returns flow conditions for this job.


[:get] /replica/killed-jobs

michaels-mbp-4:lib-onyx michael$ http --json http://localhost:3000/completed-jobs
HTTP/1.1 200 OK
Content-Length: 100
Content-Type: application/json
Date: Mon, 22 Feb 2016 03:04:34 GMT
Server: Jetty(9.2.10.v20150310)
{
"as-of-entry": 12,
"as-of-timestamp": 1456108757818,