-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from tarent/service-discovery
Service discovery
- Loading branch information
Showing
11 changed files
with
215 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package composition | ||
|
||
import ( | ||
"github.com/tarent/lib-servicediscovery/servicediscovery" | ||
) | ||
|
||
// Fluent-interface decorator for the FetchDefinition that activates the ServiceDiscovery | ||
func (d *FetchDefinition) DiscoveredBy(dnsServer string) *FetchDefinition { | ||
|
||
serviceDiscovery, err := servicediscovery.NewConsulServiceDiscovery(dnsServer) | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
d.ServiceDiscovery = serviceDiscovery | ||
d.ServiceDiscoveryActive = true | ||
|
||
return d | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package composition | ||
|
||
import ( | ||
"testing" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_FetchDefinition_DiscoveredBy(t *testing.T) { | ||
a := assert.New(t) | ||
|
||
testSubject := FetchDefinition{} | ||
|
||
testSubject.DiscoveredBy("127.0.0.1:53") | ||
|
||
a.NotNil(testSubject.ServiceDiscovery) | ||
a.True(testSubject.ServiceDiscoveryActive) | ||
} | ||
|
||
func Test_FetchDefinition_DiscoveredByError(t *testing.T) { | ||
a := assert.New(t) | ||
|
||
testSubject := FetchDefinition{} | ||
|
||
a.Panics(func() { | ||
testSubject.DiscoveredBy("a") | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters