(TK-27) Remove persistent namespaces
Remove persistent-async and persistent-sync namespaces, moving their contents into async and sync, respectively.
This commit is contained in:
parent
849b209bae
commit
81cd0eabaf
6 changed files with 58 additions and 78 deletions
|
@ -301,6 +301,32 @@
|
|||
(future-callback client result opts callback))
|
||||
result)))
|
||||
|
||||
(schema/defn create-client :- common/HTTPClient
|
||||
[opts :- common/ClientOptions]
|
||||
(let [opts (configure-ssl opts)
|
||||
client (if (:ssl-context opts)
|
||||
(.. (HttpAsyncClients/custom) (setSSLContext (:ssl-context opts)) build)
|
||||
(HttpAsyncClients/createDefault))]
|
||||
(.start client)
|
||||
(reify common/HTTPClient
|
||||
(get [this url] (common/get this url {}))
|
||||
(get [_ url opts] (request (assoc opts :method :get :url url) nil client))
|
||||
(head [this url] (common/head this url {}))
|
||||
(head [_ url opts] (request (assoc opts :method :head :url url) nil client))
|
||||
(post [this url] (common/post this url {}))
|
||||
(post [_ url opts] (request (assoc opts :method :post :url url) nil client))
|
||||
(put [this url] (common/put this url {}))
|
||||
(put [_ url opts] (request (assoc opts :method :put :url url) nil client))
|
||||
(delete [this url] (common/delete this url {}))
|
||||
(delete [_ url opts] (request (assoc opts :method :delete :url url) nil client))
|
||||
(trace [this url] (common/trace this url {}))
|
||||
(trace [_ url opts] (request (assoc opts :method :trace :url url) nil client))
|
||||
(options [this url] (common/options this url {}))
|
||||
(options [_ url opts] (request (assoc opts :method :options :url url) nil client))
|
||||
(patch [this url] (common/patch this url {}))
|
||||
(patch [_ url opts] (request (assoc opts :method :patch :url url) nil client))
|
||||
(close [_] (.close client)))))
|
||||
|
||||
(defn get
|
||||
"Issue an asynchronous HTTP GET request. This will raise an exception if an
|
||||
error is returned."
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
(ns puppetlabs.http.client.persistent-async
|
||||
(:import (org.apache.http.impl.nio.client HttpAsyncClients))
|
||||
(:require [schema.core :as schema]
|
||||
[puppetlabs.http.client.common :as common]
|
||||
[puppetlabs.http.client.common :as common]
|
||||
[puppetlabs.http.client.async :refer [request configure-ssl]])
|
||||
(:refer-clojure :exclude (get)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; Public
|
||||
|
||||
(schema/defn create-client :- common/HTTPClient
|
||||
[opts :- common/ClientOptions]
|
||||
(let [opts (configure-ssl opts)
|
||||
client (if (:ssl-context opts)
|
||||
(.. (HttpAsyncClients/custom) (setSSLContext (:ssl-context opts)) build)
|
||||
(HttpAsyncClients/createDefault))]
|
||||
(.start client)
|
||||
(reify common/HTTPClient
|
||||
(get [this url] (common/get this url {}))
|
||||
(get [_ url opts] (request (assoc opts :method :get :url url) nil client))
|
||||
(head [this url] (common/head this url {}))
|
||||
(head [_ url opts] (request (assoc opts :method :head :url url) nil client))
|
||||
(post [this url] (common/post this url {}))
|
||||
(post [_ url opts] (request (assoc opts :method :post :url url) nil client))
|
||||
(put [this url] (common/put this url {}))
|
||||
(put [_ url opts] (request (assoc opts :method :put :url url) nil client))
|
||||
(delete [this url] (common/delete this url {}))
|
||||
(delete [_ url opts] (request (assoc opts :method :delete :url url) nil client))
|
||||
(trace [this url] (common/trace this url {}))
|
||||
(trace [_ url opts] (request (assoc opts :method :trace :url url) nil client))
|
||||
(options [this url] (common/options this url {}))
|
||||
(options [_ url opts] (request (assoc opts :method :options :url url) nil client))
|
||||
(patch [this url] (common/patch this url {}))
|
||||
(patch [_ url opts] (request (assoc opts :method :patch :url url) nil client))
|
||||
(close [_] (.close client)))))
|
|
@ -1,37 +0,0 @@
|
|||
(ns puppetlabs.http.client.persistent-sync
|
||||
(:import (org.apache.http.impl.nio.client HttpAsyncClients))
|
||||
(:require [schema.core :as schema]
|
||||
[puppetlabs.http.client.common :as common]
|
||||
[puppetlabs.http.client.common :as common]
|
||||
[puppetlabs.http.client.sync :refer [request]]
|
||||
[puppetlabs.http.client.async :refer [configure-ssl]])
|
||||
(:refer-clojure :exclude (get)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;; Public
|
||||
|
||||
(schema/defn create-client :- common/HTTPClient
|
||||
[opts :- common/ClientOptions]
|
||||
(let [opts (configure-ssl opts)
|
||||
client (if (:ssl-context opts)
|
||||
(.. (HttpAsyncClients/custom) (setSSLContext (:ssl-context opts)) build)
|
||||
(HttpAsyncClients/createDefault))]
|
||||
(.start client)
|
||||
(reify common/HTTPClient
|
||||
(get [this url] (common/get this url {}))
|
||||
(get [_ url opts] (request (assoc opts :method :get :url url) client))
|
||||
(head [this url] (common/head this url {}))
|
||||
(head [_ url opts] (request (assoc opts :method :head :url url) client))
|
||||
(post [this url] (common/post this url {}))
|
||||
(post [_ url opts] (request (assoc opts :method :post :url url) client))
|
||||
(put [this url] (common/put this url {}))
|
||||
(put [_ url opts] (request (assoc opts :method :put :url url) client))
|
||||
(delete [this url] (common/delete this url {}))
|
||||
(delete [_ url opts] (request (assoc opts :method :delete :url url) client))
|
||||
(trace [this url] (common/trace this url {}))
|
||||
(trace [_ url opts] (request (assoc opts :method :trace :url url) client))
|
||||
(options [this url] (common/options this url {}))
|
||||
(options [_ url opts] (request (assoc opts :method :options :url url) client))
|
||||
(patch [this url] (common/patch this url {}))
|
||||
(patch [_ url opts] (request (assoc opts :method :patch :url url) client))
|
||||
(close [_] (.close client)))))
|
|
@ -2,7 +2,10 @@
|
|||
;; defined in puppetlabs.http.client
|
||||
|
||||
(ns puppetlabs.http.client.sync
|
||||
(:require [puppetlabs.http.client.async :as async])
|
||||
(:import (org.apache.http.impl.nio.client HttpAsyncClients))
|
||||
(:require [puppetlabs.http.client.async :as async]
|
||||
[schema.core :as schema]
|
||||
[puppetlabs.http.client.common :as common])
|
||||
(:refer-clojure :exclude (get)))
|
||||
|
||||
(defn request
|
||||
|
@ -17,6 +20,32 @@
|
|||
(throw error)
|
||||
resp))))
|
||||
|
||||
(schema/defn create-client :- common/HTTPClient
|
||||
[opts :- common/ClientOptions]
|
||||
(let [opts (async/configure-ssl opts)
|
||||
client (if (:ssl-context opts)
|
||||
(.. (HttpAsyncClients/custom) (setSSLContext (:ssl-context opts)) build)
|
||||
(HttpAsyncClients/createDefault))]
|
||||
(.start client)
|
||||
(reify common/HTTPClient
|
||||
(get [this url] (common/get this url {}))
|
||||
(get [_ url opts] (request (assoc opts :method :get :url url) client))
|
||||
(head [this url] (common/head this url {}))
|
||||
(head [_ url opts] (request (assoc opts :method :head :url url) client))
|
||||
(post [this url] (common/post this url {}))
|
||||
(post [_ url opts] (request (assoc opts :method :post :url url) client))
|
||||
(put [this url] (common/put this url {}))
|
||||
(put [_ url opts] (request (assoc opts :method :put :url url) client))
|
||||
(delete [this url] (common/delete this url {}))
|
||||
(delete [_ url opts] (request (assoc opts :method :delete :url url) client))
|
||||
(trace [this url] (common/trace this url {}))
|
||||
(trace [_ url opts] (request (assoc opts :method :trace :url url) client))
|
||||
(options [this url] (common/options this url {}))
|
||||
(options [_ url opts] (request (assoc opts :method :options :url url) client))
|
||||
(patch [this url] (common/patch this url {}))
|
||||
(patch [_ url opts] (request (assoc opts :method :patch :url url) client))
|
||||
(close [_] (.close client)))))
|
||||
|
||||
(defn get
|
||||
"Issue a synchronous HTTP GET request. This will raise an exception if an
|
||||
error is returned."
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
[puppetlabs.trapperkeeper.services.webserver.jetty9-service :as jetty9]
|
||||
[puppetlabs.http.client.common :as common]
|
||||
[puppetlabs.http.client.async :as async]
|
||||
[puppetlabs.http.client.persistent-async :as p-async]
|
||||
[schema.test :as schema-test]))
|
||||
|
||||
(use-fixtures :once schema-test/validate-schemas)
|
||||
|
@ -81,7 +80,7 @@
|
|||
(testutils/with-app-with-config app
|
||||
[jetty9/jetty9-service test-web-service]
|
||||
{:webserver {:port 10000}}
|
||||
(let [client (p-async/create-client {})]
|
||||
(let [client (async/create-client {})]
|
||||
(testing "HEAD request with persistent async client"
|
||||
(let [response (common/head client "http://localhost:10000/hello/")]
|
||||
(is (= 200 (:status @response)))
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
[puppetlabs.trapperkeeper.testutils.logging :as testlogging]
|
||||
[puppetlabs.trapperkeeper.services.webserver.jetty9-service :as jetty9]
|
||||
[puppetlabs.http.client.sync :as sync]
|
||||
[puppetlabs.http.client.persistent-sync :as p-sync]
|
||||
[puppetlabs.http.client.common :as common]
|
||||
[schema.test :as schema-test]
|
||||
[clojure.java.io :as io]))
|
||||
|
@ -86,7 +85,7 @@
|
|||
(testutils/with-app-with-config app
|
||||
[jetty9/jetty9-service test-web-service]
|
||||
{:webserver {:port 10000}}
|
||||
(let [client (p-sync/create-client {})]
|
||||
(let [client (sync/create-client {})]
|
||||
(testing "HEAD request with persistent sync client"
|
||||
(let [response (common/head client "http://localhost:10000/hello/")]
|
||||
(is (= 200 (:status response)))
|
||||
|
|
Loading…
Reference in a new issue