puppetlabs/trapperkeeper

Support multi-arity fn in protocols

Closed this issue · 2 comments

I stumble upon the following error:

Incorrect macro usage: service functions must be defined the same as a call to `reify`, eg: `(my-service-fn [this other-args] ...)`

When trying to implement a service for a protocol like the following:

(defprotocol SearchStoreService
  (search
    [this db pattern]
    [this db pattern options]))

(tk/defservice search-store-service
  SearchStoreService
  [[:ConfigService get-in-config]]

   ...

(search
   ([this db pattern]
    (search db pattern nil))
   ([this db pattern options]
    (if-let [db-conf (get-in (service-context this) [:stores db])]
      (core/search db-conf pattern options)
      (log/errorf "Unknown db (%s)" db))))

My bad, I didn't used the same syntax.

Thanks!