像 clojure 一样思考函数式,这对 JVM 来说更好、性能更高、负担更轻
(defn- on-message
([options ch {:keys [headers delivery-tag]} ^bytes payload ^CompanyProto$Company$Builder company]
(check-id company)
(save company options)
(basic/ack ch delivery-tag))
([options ch ^PersistentHashMap kwargs ^bytes payload]
(on-message options
ch
kwargs
payload
(-> (CompanyProto$Company/newBuilder)
(.mergeFrom payload)))))
或者
(defn- on-message [options ch {:keys [headers delivery-tag] ^bytes payload}]
(let [company (-> (CompanyProto$Company/newBuilder) (.mergeFrom payload))]
(check-id company)
(save company options)
(basic/ack ch delivery-tag)))