-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #97 from yetanalytics/pip-81
[PIP 81] - Toggle JSON-Only
- Loading branch information
Showing
11 changed files
with
91 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
(ns com.yetanalytics.xapipe.client.json-only | ||
"JSON-only statement response handling. Necessary over default JSON parsing | ||
to shim attachments which will not exist" | ||
(:require [clj-http.client :as http-client] | ||
[clojure.spec.alpha :as s] | ||
[com.yetanalytics.xapipe.client.multipart-mixed :as mm])) | ||
|
||
(s/def ::body | ||
(s/keys :req-un | ||
[:xapi.statements.GET.response/statement-result | ||
::mm/attachments])) | ||
|
||
(s/fdef parse-response | ||
:args (s/cat :response map?) | ||
:ret (s/keys :req-un [::body])) | ||
|
||
(defn parse-response | ||
"Parse + close a json body" | ||
[req resp] | ||
(let [{:keys [body]} (http-client/coerce-json-body req resp false)] | ||
(assoc resp :body {:attachments [] | ||
:statement-result | ||
(reduce-kv | ||
(fn [m k v] | ||
(assoc m (keyword k) v)) | ||
{} | ||
body)}))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ | |
:source-poll-interval 1000, | ||
:get-params {}, | ||
:source-backoff-budget 10000, | ||
:json-only false | ||
:source-backoff-max-attempt 10} | ||
nil | ||
|
||
|
@@ -66,6 +67,7 @@ | |
:source-poll-interval 1000, | ||
:get-params {}, | ||
:source-backoff-budget 10000, | ||
:json-only false | ||
:source-backoff-max-attempt 10} | ||
["Failed to validate \"--source-batch-size 0\": Must be a positive integer"] | ||
|
||
|
@@ -80,6 +82,7 @@ | |
:get-params {:since "2021-10-26T17:51:06.530464Z" | ||
:related_agents true}, | ||
:source-backoff-budget 10000, | ||
:json-only false | ||
:source-backoff-max-attempt 10} | ||
nil)) | ||
|
||
|
@@ -129,6 +132,7 @@ | |
:target-backoff-budget 10000, | ||
:force-resume false, | ||
:redis-prefix "xapipe", | ||
:json-only false | ||
:storage :file, | ||
:get-buffer-size 10, | ||
:target-batch-size 50, | ||
|
@@ -157,9 +161,10 @@ | |
:cleanup-buffer-size 50, | ||
:source | ||
{:request-config | ||
{:url-base "http://0.0.0.0:8080", :xapi-prefix "/xapi"}, | ||
{:url-base "http://0.0.0.0:8080", | ||
:xapi-prefix "/xapi"}, | ||
:batch-size 50, | ||
:backoff-opts {:budget 10000, :max-attempt 10}, | ||
:backoff-opts {:budget 10000, :max-attempt 10} | ||
:poll-interval 1000, | ||
:get-params {:limit 50}}, | ||
:target | ||
|
@@ -215,6 +220,7 @@ | |
"--xapi-get-param" "format=exact" | ||
"--source-username" "foo" | ||
"--source-password" "bar" | ||
"--json-only" | ||
"--source-backoff-budget" "1" | ||
"--source-backoff-max-attempt" "1" | ||
"--source-backoff-j-range" "1" | ||
|
@@ -275,6 +281,7 @@ | |
:force-resume true, | ||
:redis-prefix "my-xapipe", | ||
:source-backoff-j-range 1, | ||
:json-only true, | ||
:storage :file, | ||
:get-buffer-size 1, | ||
:target-backoff-initial 1, | ||
|
@@ -291,15 +298,15 @@ | |
:metrics-reporter "prometheus" | ||
:prometheus-push-gateway "localhost:1234" | ||
:filter-ensure-paths [[["id"]]] | ||
:filter-match-paths [[[["verb"]["id"]] | ||
:filter-match-paths [[[["verb"] ["id"]] | ||
"http://example.com/verb"] | ||
[[["actor"]] {"mbox" "mailto:[email protected]" | ||
"objectType" "Agent"}]] | ||
:filter-concept-profile-urls ["http://example.org/profile.jsonld"] | ||
:filter-concept-types ["Verb"] | ||
:filter-activity-type-ids [ "http://example.org/profile.jsonld#activity-type"] | ||
:filter-activity-type-ids ["http://example.org/profile.jsonld#activity-type"] | ||
:filter-verb-ids ["http://example.org/profile.jsonld#verb"] | ||
:filter-attachment-usage-types [ "http://example.org/profile.jsonld#aut"] | ||
:filter-attachment-usage-types ["http://example.org/profile.jsonld#aut"] | ||
:cleanup-buffer-size 1} | ||
[]) | ||
(testing "no defaults" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters