New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sleuth implementation #2

Merged
merged 1 commit into from Jun 3, 2016
Jump to file or symbol
Failed to load files and symbols.
+20 −3
Diff settings

Always

Just for now

View
@@ -10,12 +10,13 @@ import (
"github.com/afshin/sleuth-example/types"
"github.com/gorilla/mux"
"github.com/ursiform/sleuth"
)
const commentsURL = "http://localhost:9871/comments/%s"
const commentsURL = "sleuth://comment-service/comments/%s"
var (
client = new(http.Client)
client *sleuth.Client
data = make(map[string]*types.Article) // Key is article GUID.
)
@@ -83,6 +84,12 @@ func handler(res http.ResponseWriter, req *http.Request) {
func main() {
router := mux.NewRouter()
router.HandleFunc("/articles/{guid}", handler).Methods("GET")
// In the real world, the Interface field of the sleuth.Config object
// should be set so that all services are on the same subnet.
client, _ = sleuth.New(&sleuth.Config{})
client.WaitFor("comment-service")
fmt.Println("ready...")
http.ListenAndServe(":9872", router)
}
View
@@ -9,9 +9,13 @@ import (
"github.com/afshin/sleuth-example/types"
"github.com/gorilla/mux"
"github.com/ursiform/sleuth"
)
var data = make(map[string][]*types.Comment) // Key is article GUID.
var (
client *sleuth.Client
data = make(map[string][]*types.Comment) // Key is article GUID.
)
func init() {
var err error
@@ -49,6 +53,12 @@ func handler(res http.ResponseWriter, req *http.Request) {
func main() {
router := mux.NewRouter()
router.HandleFunc("/comments/{guid}", handler).Methods("GET")
// In the real world, the Interface field of the sleuth.Config object
// should be set so that all services are on the same subnet.
config := &sleuth.Config{Service: "comment-service", Handler: router}
client, _ = sleuth.New(config)
fmt.Println("ready...")
http.ListenAndServe(":9871", router)
}
ProTip! Use n and p to navigate between commits in a pull request.