Skip to content

Support multi-arity fn in protocols #267

Closed
@yogsototh

Description

@yogsototh

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))))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions