Created
January 20, 2017 10:06
-
-
Save terry3/61acd31c44c9222ad97e89909368310a to your computer and use it in GitHub Desktop.
git lang ana core.clj
This file contains hidden or 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
(ns git-lang-ana.core | |
(:require [clj-http.client :as client]) | |
(:gen-class)) | |
(import '(java.util TimerTask Timer)) | |
(defn every [time f & args] | |
(let [task (proxy [TimerTask] [] | |
(run [] (apply f args)))] | |
(. (new Timer) (schedule task 0 (* 1000 time))))) | |
(defn gla-exception-handler [exception] | |
(println "exception message is: " (.getMessage exception))) | |
(defn gla-fetch-repo [] | |
(println (new java.util.Date)) | |
(client/get "http://www.baidu.com" | |
{:async? true} | |
;; respond callback | |
(fn [response] | |
(println "response is:" response)) | |
;; raise callback | |
(fn [exception] | |
(gla-exception-handler exception)))) | |
(defn gla-fetch-repo-sync [] | |
(println (new java.util.Date)) | |
(println (:status (client/get "http://site.com/resources/id")))) | |
(defn -main | |
[& args] | |
(every 5 gla-fetch-repo-sync)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment