Skip to content
This repository has been archived by the owner on Apr 15, 2018. It is now read-only.

Consul support as coordination service #12

Merged
merged 1 commit into from
Nov 27, 2015

Conversation

juanjovazquez
Copy link
Contributor

Proposal to incorporate Consul as other possible coordination service in addition to etcd.

@@ -70,8 +70,8 @@ abstract class MultiNodeConstructrSpec extends MultiNodeSpec(ConstructrMultiNode

"Constructr should manage an Akka cluster" in {
runOn(nodes.head) {
"docker rm -f constructr-etcd".!(ProcessLogger(_ => ()))
s"""docker run --name constructr-etcd -d -p 2379:2379 quay.io/coreos/etcd:v2.2.1 -advertise-client-urls http://$host:2379 -listen-client-urls http://0.0.0.0:2379""".!
"docker-machine ssh default docker rm -f constructr-etcd".!(ProcessLogger(_ => ()))
Copy link
Owner

Choose a reason for hiding this comment

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

What's the purpose of this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We'll remove this change as we've seen that is not necessary.

This was referenced Nov 25, 2015
case Event(Coordination.SelfAdded(context), _) =>
goto(State.RefreshScheduled).using(stateData.copy(
coordinationRetriesLeft = coordinationRetries,
context = context.asInstanceOf[B#Context]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is ugly but we haven't found a cleaner version.

Copy link
Owner

Choose a reason for hiding this comment

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

;-)
I think you should simply use a typed pattern in the pattern match three lines above:

case Event(Coordination.SelfAdded(context: B#Context), _) => ...

@hseeberger
Copy link
Owner

Great stuff! I have a couple of minor style related changes. I assume the test passes? ;-)

@hseeberger
Copy link
Owner

May I also ask you to squash the various commits into one with a short and meaningful name, e.g. "Add support for Consul"?

def toNodes(s: String) = {
import rapture.json._
import rapture.json.jsonBackends.spray._
def jsonToNode(json: Json) = {
Copy link
Owner

Choose a reason for hiding this comment

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

More nitpicks ;-)
These curly braces aren't needed. Move the next line up, just after the equals sign.

@hseeberger
Copy link
Owner

Looks really good. Just some more nitpicks (sorry, I'm German, it's in my blood).

@juanjovazquez
Copy link
Contributor Author

LOL No problem!. I'll fix this minor issues right away. Thanks!.

@@ -147,7 +147,11 @@ final class ConstructrMachine[A: Coordination.AddressSerialization, B <: Coordin
}

when(State.AddingSelf, coordinationTimeout) {
case Event(Coordination.SelfAdded(_), _) => goto(State.RefreshScheduled).using(stateData.copy(coordinationRetriesLeft = coordinationRetries))
case Event(Coordination.SelfAdded(context: B#Context), _) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@hseeberger, this is an unchecked type pattern. We're facing a compile-time warning because of that:

Warning:(150, 50) abstract type pattern B#Context is unchecked since it is eliminated by erasure
    case Event(Coordination.SelfAdded(context: B#Context), _) =>

How do you prefer to deal with it?

Copy link
Owner

Choose a reason for hiding this comment

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

Add an @unchecked annotation, like above in line 113 case Event(nodes: List[A] @unchecked, _) => ....

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perfect.

@juanjovazquez
Copy link
Contributor Author

@hseeberger, new installment trying to be more descriptive. Eliminated some duplications also.

@hseeberger
Copy link
Owner

This is awesome work. Thanks!

hseeberger added a commit that referenced this pull request Nov 27, 2015
Consul support as coordination service
@hseeberger hseeberger merged commit 6a1a639 into hseeberger:master Nov 27, 2015
@juanjovazquez juanjovazquez deleted the consul-support-delta branch November 27, 2015 18:56
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