Skip to content
This repository has been archived by the owner on Mar 11, 2020. It is now read-only.

Add Service Lookups (WIP) #4

Closed
wants to merge 1 commit into from

Conversation

jasonmartens
Copy link
Contributor

I would like to add the ability to query the service catalog in Consul. I tried adding the following, but I'm getting a test failure: "could not match expected pattern (ConsulOpTests.scala:73)". For the second test, I don't understand how to decode the JSON consul returns which doesn't have a key, but is just an array like in the mock response.

Any help is greatly appreciated. I'm a little lost in functional land here. ;-)

@jasonmartens
Copy link
Contributor Author

Can anyone comment on this? Point me in the right direction?

case ConsulOp.GetCatalogServices => now(Some("""{"consul":[],"service-name":["tag1","tag2"]}"""))
}
} yield ()
interp.run(getJson[Json]("service-name")).run should equal(\/.right(Some(List("tag1","tag2"))))
Copy link
Contributor

@kaiserpelagic kaiserpelagic Jun 8, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want to be calling getJson here as that's a top level api that calls consul's key value api and decodes the result as json.

see here: https://github.com/Verizon/helm/blob/master/core/src/main/scala/HelmOp.scala#L33

What you probably want to do is follow this pattern with your code. So you'd have

def getService(service: String): ConsulOpF[Option[String]]

and then another top level method that calls getService and decodes the json with the given deocder.

def getServiceJson[A:DecodeJson](service: String): ConsulOpF[Err \/ Option[A]]

@jasonmartens
Copy link
Contributor Author

Thanks for the comment. I've gone ahead with another client library, so don't need this PR merged any longer.

goedelsoup pushed a commit to compstak/helm that referenced this pull request Feb 18, 2019
Updated README accordingly to the latest release version.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants