差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

Both sides previous revision 前次修改
下次修改
前次修改
methodology:arch:changedevent [2016/09/29 23:17]
tony [Hook Scripts]
methodology:arch:changedevent [2023/06/25 09:48] (目前版本)
行 1: 行 1:
-====== 如何讓Client得知你系統的事件? ​(工作中) ​======+{{tag>​webook PubSubHubBub pub/sub}} 
 +====== 如何讓Client得知你系統的事件?​ ======
 ===== Introduction ===== ===== Introduction =====
 不管是任何系統都會有自己特有事件,而使用者會對某些事件有興趣。對於不同的案例,會有不同的解法。這裡主要收集Study的結果。 不管是任何系統都會有自己特有事件,而使用者會對某些事件有興趣。對於不同的案例,會有不同的解法。這裡主要收集Study的結果。
 ===== Categories ===== ===== Categories =====
 ==== WebHook - Pub/Sub ==== ==== WebHook - Pub/Sub ====
-在這種方法中,Client扮演著subscriber;Server則為publisher。Client會透過Server提供的介面去註冊某個有興趣的訊息,而Server當發生了事件後,會把訊息送給對應的subscriber。\\+在這種方法中,Client扮演著subscriber;Server則為publisher。Client會透過Server提供的介面去註冊某個有興趣的訊息,而Server當發生了事件後,會把訊息送給對應的subscriber。參考Jenkins Notification Plugin的UI設計:​ (圖片來自:​ [[https://​wiki.jenkins-ci.org/​display/​JENKINS/​Notification+Plugin|link]])\\ 
 +{{:​methodology:​arch:​jenkins_plugin_notification.png|}}\\ 
 +以Jenkins的Plugin來說,User可以透過它的UI設定你的Client所接受的Format、Protocol(http、https、udp、tcp),有興趣的Event,還有要callback的URL。如果你的Server提供的介面是RestAPI,可以參考Google Drive的做法。最重要的就在於User願意接受你所提出的格式。\\
 \\ \\
 使用這方法的應用有:​ [[https://​developers.google.com/​drive/​v3/​web/​push|Google Drive]]、[[https://​azure.microsoft.com/​en-us/​documentation/​articles/​app-service-api-dotnet-triggers/​|AZure]]、[[https://​wiki.jenkins-ci.org/​display/​JENKINS/​Notification+Plugin|Jenkins Plugin]]。 使用這方法的應用有:​ [[https://​developers.google.com/​drive/​v3/​web/​push|Google Drive]]、[[https://​azure.microsoft.com/​en-us/​documentation/​articles/​app-service-api-dotnet-triggers/​|AZure]]、[[https://​wiki.jenkins-ci.org/​display/​JENKINS/​Notification+Plugin|Jenkins Plugin]]。
行 29: 行 32:
 使用這方法的應用有:​ [[https://​www.dropbox.com/​developers-v1/​core/​docs|Dropbox]],。 使用這方法的應用有:​ [[https://​www.dropbox.com/​developers-v1/​core/​docs|Dropbox]],。
 ==== Hook Scripts ==== ==== Hook Scripts ====
-{{:​methodology:​arch:​git_hook.png?​600|}}\\+我最早使用Hook Scripts是在SVN時期,它可以針對不同事件發生時,執行你所提供的腳本。例如commit code後,觸發持續整合系統的建置;在commit之前,必須先做某些事情才允許commit等。(圖片來自:​ [[https://​fr.atlassian.com/​git/​tutorials/​git-hooks/​conceptual-overview|link]])\\ 
 +{{:​methodology:​arch:​git_hook.png?​700|}}\\ 
 +以Git Hook範例來說,在第二步驟執行後,會觸發Pre-Commit Notification;在Pre-Commit Notification成功後,接著執行第三步驟後,會觸發Post-Commit Notification。\\ 
 +\\ 
 +如果提供Hook Scripts的方式,你可以不需要管Client長什麼樣,因為User可以根據它的需求去做對應的Script出來。(如果他提供無法跑的Script,那就是來亂的無誤)\\
 \\ \\
 使用這方法的應用有:​ [[https://​git-scm.com/​book/​zh-tw/​v1/​Git-%E5%AE%A2%E8%A3%BD%E5%8C%96-Git-Hooks|Git]]、[[http://​jdev.tw/​blog/​340/​subversion-hook-scripts|Subversion]]。 使用這方法的應用有:​ [[https://​git-scm.com/​book/​zh-tw/​v1/​Git-%E5%AE%A2%E8%A3%BD%E5%8C%96-Git-Hooks|Git]]、[[http://​jdev.tw/​blog/​340/​subversion-hook-scripts|Subversion]]。
行 40: 行 47:
   * [[https://​en.wikipedia.org/​wiki/​Publish%E2%80%93subscribe_pattern|Publish–subscribe pattern]]   * [[https://​en.wikipedia.org/​wiki/​Publish%E2%80%93subscribe_pattern|Publish–subscribe pattern]]
   * [[https://​blog.gtwang.org/​web-development/​websocket-protocol/​|WebSocket 通訊協定簡介:比較 Polling、Long-Polling 與 Streaming 的運作原理]]   * [[https://​blog.gtwang.org/​web-development/​websocket-protocol/​|WebSocket 通訊協定簡介:比較 Polling、Long-Polling 與 Streaming 的運作原理]]
 +  * [[https://​fr.atlassian.com/​git/​tutorials/​git-hooks/​conceptual-overview|git-hooks]]
  
 ====== ​ ====== ====== ​ ======