2012-05-03 11 views
6

Mam biblioteki Clojure, który określa protokół MQHandle i rozciąga ją„Żadna metoda [...] znalezionych dla funkcji” próbuje użyć protokołu

(ns example.mq 
    (:import [java.util.concurrent BlockingQueue])) 

(defprotocol MQHandle 
    (send-message [this key body & params]) 

(extend-type BlockingQueue 
    MQHandle 
    (send-message [this key body & params] 
    (.put this (merge {::key key, ::body body} 
         (into {} (partition 2 params))))) 

(defn get-handle ^BlockingQueue [& config] 
    "return a BlockingQueue tied to a thread which consumes messages 
    and submits them to a remote message queue" 
    ...) 

... ale gdy próbuję użyj go:

(require '[example.mq :as mq]) 

(def handle (mq/get-handle config)) 

(satisfies? mq/MQHandle handle) 
; => true 

(mq/send-message handle "key" "body") 
; java.lang.IllegalArgumentException: No single method: send_message of interface: 
; com.indeed.clojure_network_repl.mq.MQHandle found for function: send-message of 
; protocol: MQHandle 

Nie rozumiem znaczenia tego wyjątku ani tego, co powinienem robić inaczej.

Odpowiedz

12

Funkcje protokołu nie obsługują argumentów spoczynkowych.

Powiązane problemy