puppetlabs/trapperkeeper

Subsequent multiple arity fns in protocols don't see service-context from 0.5.x

Closed this issue · 1 comments

(defprotocol DbService
  (conn [this] [this uri-key]))

(tk/defservice db-service
  DbService
  [[:ConfigService get-in-config]]
  (init [this context])
  (start [this context])
  (conn [this]
    (service-context this))
  (conn [this uri-key]
    (service-context this)))

In 0.4.3 this works fine, but that second service-context call has this error on 0.5.x:

java.lang.RuntimeException: Unable to resolve symbol: service-context in this context

Hi @robert-stuttaford, thanks a lot for the bug report.

The problem you've hit here is due to a slight API-breaking change we introduced in 0.5.0. I just updated the changelog to call this out (better late than never, right?)

The error you're getting in the code above actually has nothing to do with the fact that you have multiple arities of conn - you can remove either version of conn and you'll still get the same error. To fix this code, you simply need to add (require '[puppetlabs.trapperkeeper.services :refer [service-context]]).

I'm going to close this issue out, but please let us know if you run into any more problems!