123456789101112131415161718192021222324252627282930 |
- package main
- import (
- "../service"
- "context"
- "github.com/smallnest/rpcx/server"
- "log"
- "strings"
- )
- const ADDRESS string = "localhost:10001"
- type FormatData struct{}
- func (fd *FormatData) DoFormat(ctx context.Context, args *service.Args, reply *service.Replay) error {
- str := args.Text
- reply.Text = strings.ToUpper(str)
- return nil
- }
- func main() {
- s := server.NewServer()
- err := s.RegisterName("Format", new(FormatData), "")
- if err != nil {
- log.Fatalln("faile register service: Format")
- }
- if err = s.Serve("tcp", ADDRESS); err != nil {
- log.Fatalln("faile serve at: " + ADDRESS)
- }
- }
|