在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:koding/kite开源软件地址:https://github.com/koding/kite开源编程语言:Go 96.5%开源软件介绍:Kite Micro-Service FrameworkKite is a framework for developing micro-services in Go. Kite is both the name of the framework and the micro-service that is written by using this framework. Basically, Kite is a RPC server as well as a client. It connects to other kites and peers to communicate with each other. They can discover other kites using a service called Kontrol, and communicate with them bidirectionaly. The communication protocol uses a WebSocket (or XHR) as transport in order to allow web applications to connect directly to kites. Kites can talk with each other by sending dnode messages over a socket session. If the client knows the URL of the server kite it can connect to it directly. If the URL is not known, client can ask for it from Kontrol (Service Discovery). For more info checkout the blog post at GopherAcademy which explains Kite in more detail: http://blog.gopheracademy.com/birthday-bash-2014/kite-microservice-library/ Install and UsageInstall the package with: go get github.com/koding/kite Import it with: import "github.com/koding/kite" and use What is Kontrol?Kontrol is the service registry and authentication service used by Kites. It is itself a kite too. When a kite starts to run, it can registers itself to Kontrol with the
Query has 7 fields:
Installing KontrolInstall Kontrol:
Generate keys for the Kite key:
Set environment variables:
Generate initial Kite key:
How can I use kites from a browser?A browser can also be a Kite. It has it's own methods ("log" for logging a message to the console, "alert" for displaying alert to the user, etc.). A connected kite can call methods defined on the webpage. See kite.js library for more information. How can I write a new kite?
Below you can find an example, a math kite which calculates the square of a received number: package main
import "github.com/koding/kite"
func main() {
// Create a kite
k := kite.New("math", "1.0.0")
// Add our handler method with the name "square"
k.HandleFunc("square", func(r *kite.Request) (interface{}, error) {
a := r.Args.One().MustFloat64()
result := a * a // calculate the square
return result, nil // send back the result
}).DisableAuthentication()
// Attach to a server with port 3636 and run it
k.Config.Port = 3636
k.Run()
} Now let's connect to it and send a package main
import (
"fmt"
"github.com/koding/kite"
)
func main() {
k := kite.New("exp2", "1.0.0")
// Connect to our math kite
mathWorker := k.NewClient("http://localhost:3636/kite")
mathWorker.Dial()
response, _ := mathWorker.Tell("square", 4) // call "square" method with argument 4
fmt.Println("result:", response.MustFloat64())
} Check out the examples folder for more examples. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论