These are chat archives for spring-cloud/spring-cloud

4th
May 2016
Piotr Lewandowski
@navaro1
May 04 2016 12:15
Hello guys :)
I have question about Cloud Consul and HAProxy
maybe someone will be able to help
Piotr Lewandowski
@navaro1
May 04 2016 12:26
We (me and my teammates) are working on legacy system withing corporate settings and try to carve out some microservices, but of course we are facing some obstacles. We decided to go with Spring Cloud (Consul) and it works extremally nice, but - we were told that we have to use HAProxy as a load balancer. So we cannot use nice spring client-side balancing. So we are thinking if following is possible:
  1. Our service register itself within Consul
  2. Consul in some way (how?) register our service to HAProxy (or sth similar. I am open to suggestions)
  3. We want to identify our service via DNS, and identify instance of our service using HAProxy (so basically load balancing)
    Is this possible? How I should go about this?
Dave Syer
@dsyer
May 04 2016 13:49
I would just use ribbon in the normal way if I were you
If it bothers you to call it "load balancing" just call it "discovery client"
I don't have an opinion on how you get HAProxy to know about your services though
Sounds like you need a PaaS
(or are building one)
Dieter Hubau
@Turbots
May 04 2016 14:20
shameless PCF plug :smile: I like it
but seriously, if you really wanna use Consul and inform HAProxy of the registered service instances, I guess you would need something like this: https://www.hashicorp.com/blog/haproxy-with-consul.html
but I guess that one is already deprecated and has now turned into https://github.com/hashicorp/consul-template
Spencer Gibb
@spencergibb
May 04 2016 14:24
Yup, was just pasting https://github.com/hashicorp/consul-template. At this point it is unrelated to spring cloud
Matt Benson
@mbenson
May 04 2016 19:29
the spring-cloud-bus README says only amqp, but there is a kafka starter. Is the README out of date? If so, is there a short form of what I need config-wise to try the kafka bus?
Dave Syer
@dsyer
May 04 2016 19:30
It's out of date, thanks
Just change the starter from stream-rabbit to stream-kafka
Matt Benson
@mbenson
May 04 2016 19:33
I'm working from unreleased stuff for now anyway, but looks like a good bit of the bus/stream stuff are unreleased, yes? Was stream extracted from bus?
wrt config, I was asking about properties
or I can just dig ;)
Dave Syer
@dsyer
May 04 2016 19:35
Stream was layered under bus (most of it came from Spring XD)
There's a user guide (section in the big one) on Stream
All the properties you would need are there
Matt Benson
@mbenson
May 04 2016 19:35
thanks Dave
Dave Syer
@dsyer
May 04 2016 19:35
But really it's just the Kafka host and port
Fixed the README
Matt Benson
@mbenson
May 04 2016 19:39
thanks
have a minute to think about config-server resource listing? Or do you want to table the whole topic until after the release?
if the core framework made it easy to support custom resource protocols, we could really do some cool stuff. I got them implemented for resource @Value autowiring anyway, and I now have pattern-based injection of resources coming from a custom endpoint on my config-server ;)
well, the ls comes from the custom endpoint, then I just create UrlResource instances pointing to the appropriate ResourceController URL
Dave Syer
@dsyer
May 04 2016 19:43
Did you raise a JIRA for that?
I'm sure there's probably something already in there
Matt Benson
@mbenson
May 04 2016 19:43
in core? Nah
i.e., Nah, I didn't raise an issue. I agree it's likely someone else has asked for it over the years
Matt Benson
@mbenson
May 04 2016 19:50
so really the only thing I'd lack to be able to create a PR for the ls functionality in spring-cloud-config-server, is a sanity check on my approach to the endpoint itself. I've created a custom Resource implementation that is annotated with Jackson annotations. On the server-side it wraps a resource and adds a "local path" which is equivalent to what a config client would ask for; on the client side it rehydrates from the JSON with the local path, last-modified time and content-length (was thinking of adding a checksum as well) so a caller of the endpoint can expect an array of these LocalResources and make the call against the resource endpoint for each... or, as I mentioned, a smart PropertyEditor can interpret @Value annotations to inject UrlResource instances.
Dave Syer
@dsyer
May 04 2016 19:51
I wouldn't want to make the hateoas dependency mandatory
Matt Benson
@mbenson
May 04 2016 19:52
is that @ me?
Dave Syer
@dsyer
May 04 2016 19:52
Yes.
Isn't that what a Resource is?
Ah, you mean spring core Resource
Matt Benson
@mbenson
May 04 2016 19:52
yes
Dave Syer
@dsyer
May 04 2016 19:53
I'd expect to see something simpler from the client
just a list of paths
This message was deleted
Matt Benson
@mbenson
May 04 2016 19:54
could do; I thought there might be some value in providing more info from the endpoint though, for caching kinds of purposes perhaps
I think I had been working with a String[] result type at some point. That would certainly avoid the question of whether Jackson annotations, etc., were appropriate, though.
would you be good with @RequestMapping("/ls/{name}/{profile}/{label}/**") for the endpoint?
on ResourceController
Dave Syer
@dsyer
May 04 2016 19:59
I'd be more inclined to use /files/{name}/{profile}/{label}
You don't need the "**" do you?
Matt Benson
@mbenson
May 04 2016 20:00
I was using it for pattern matching
Dave Syer
@dsyer
May 04 2016 20:00
That's the existing endpoint
(which arguably should have that path)
Matt Benson
@mbenson
May 04 2016 20:01
I mean, specifying an Ant-style pattern against which to match resources.
e.g., data/*.txt
seemed easier to handle once on the server rather than force each client to filter what it's interested in after the fact
Dave Syer
@dsyer
May 04 2016 20:02
I see
OK, that makes some sense
But then we could so it all in a single endpoint
Does that make sense?
Matt Benson
@mbenson
May 04 2016 20:03
like with a different result depending on whether /** is a pattern or not?
Dave Syer
@dsyer
May 04 2016 20:03
Depending on whether the path contains a pattern, or is empty, we return a listing
Yes
Matt Benson
@mbenson
May 04 2016 20:04
so the listing would be a String containing multiple paths delimited by... commas, semicolons?
Dave Syer
@dsyer
May 04 2016 20:04
It would be JSON probably
An array of String
Matt Benson
@mbenson
May 04 2016 20:06
so for my @Value example, where @Value("") might contain a pattern or a specific named resource, the client would have to check whether it specifies a pattern in order to know what kind of result was expected
it is kind of attractive not to have to add the additional path segment, which precludes the possibility of an application named ls or files or what-have-you
Dave Syer
@dsyer
May 04 2016 20:10
Yeah, there's a possible clash there.
I have to go now
Matt Benson
@mbenson
May 04 2016 20:10
sure, see you later
earlier, even