Skip to content

Latest commit

 

History

History
46 lines (38 loc) · 1.82 KB

README.md

File metadata and controls

46 lines (38 loc) · 1.82 KB

Hprose

简体中文

License codebeat badge Go Report Card GoDoc Build Status Coverage Status

Hprose based on NATs message queue

Features

  • timeout
  • lazy load
  • failround
  • load balancing

Installing

go get github.com/vlorc/hprose-go-nats

License

This project is under the apache License. See the LICENSE file for the full license text.

Examples

Client

client := rpc.NewClient("nats://localhost:4222?topic=test&timeout=1")
method := &struct{ Hello func(string) (string, error) }{}
client.UseService(method)
for i := 0; i < 10; i++ {
	log.Print(method.Hello(fmt.Sprintf("baby(%d)",i)))
}

Server

server := rpc.NewServer(rpc.NewOption(rpc.Uri("nats://localhost:4222?topic=test&group=balancer")))
server.AddFunction("hello", func(msg string) string {
	log.Print("hello: ", msg)
	return "hi bitch!"
})
server.Start()