koding / kite

Micro-service framework in Go
https://godoc.org/github.com/koding/kite
MIT License
3.26k stars 300 forks source link

Documentation on Kontrol or basic explanations ? #141

Open depado opened 8 years ago

depado commented 8 years ago

Hello,

I'm trying to use Kontrol. First of all there a things I don't understand :

Currently I'm having a single error when I try to connect my client kite to the server kite going through Kontrol. I generated the keys with the commands given in your README.md file, started etcd and then started kontrol with the -initial argument. It generated the key without a problem and then started kontrol like that :

kontrol -port=6000 -publickeyfile="certs/key_pub.pem" -privatekeyfile="certs/key.pem" -ip="127.0.0.1"

(I hope so far everything is fine)

Here is my server kite (I stripped down everything that wasn't needed) :

func main() {
    k := kite.New("bus", "1.0.0")
    c := config.MustGet()
    k.Config = c
    k.Config.Port = 6001
    k.Config.Username = "test"
    k.Config.Environment = "dev"
    k.Config.KontrolURL = "http://127.0.0.1:6000/kite"

    k.HandleFunc("square", func(r *kite.Request) (interface{}, error) {
        return "Ok", nil
    })

    k.RegisterForever(&url.URL{Scheme: "http", Host: "127.0.0.1:6001"})
    k.Run()
}

When I start this server, there is no problem, the kite registers itself with Kontrol. (Note that I ignored the error returned k.RegisterForever to simplify the snippet, but I do check it otherwise)

First thing I don't understand :

[bus] Kite Stdout :
2015-10-28 18:09:18 [bus] INFO     Registered to kontrol with URL: http://127.0.0.1:6001 and Kite query: /test/dev/bus/1.0.0/unknown/silence/0888388b-e4a3-4918-4115-82f6c98b0432

[kontrol] Kite Stdout :
2015-10-28 18:11:53 [kontrol] INFO     Register request from: /kontrol/dev/bus/1.0.0/unknown/silence/0888388b-e4a3-4918-4115-82f6c98b0432
2015-10-28 18:11:53 [kontrol] INFO     Kite registered: /kontrol/dev/bus/1.0.0/unknown/silence/0888388b-e4a3-4918-4115-82f6c98b0432

So the [bus] Kite tells me that it has registered with Kontrol, and that the query to reach him is /test/dev/bus/... but Kontrol tells me it registered to /kontrol/dev/bus/.... What am I missing here ?

And then with my client I'm getting a websocket: bad handshake but I guess my misunderstanding in the way Kontrol works caused this issue.

Also, sorry for the long post, I understand that you're busy and that you may have not the time to answer me. (And thanks for updating the example with a struct, it was helpful :smile: )

I intend to write a tutorial on Kite once I make it work fine if you don't mind :smile:

depado commented 8 years ago

Any chance someone using Kontrol could answer me ?

bhalle commented 8 years ago

@Depado did you ever get your issue resolved? I'm currently running into a similar issue with "websocket: bad handshake" when trying to get simple example running.

depado commented 8 years ago

No, I dropped it for now. I'm running things without Kontrol.

bhalle commented 8 years ago

@Depado ... ok thx

depado commented 8 years ago

@bhalle if you happen to make things work, would you mind writing down a small tutorial on how you managed to do it ? I'm still quite interested in that.

bhalle commented 8 years ago

@Depado ... here ya go ... https://github.com/bhalle/api.kite

depado commented 8 years ago

Thanks @bhalle I'll give that a try :+1: