zoukankan      html  css  js  c++  java
  • henrylee2cn简单的rpc服务

    server 端
    package controllers

    import (
    "github.com/henrylee2cn/teleport"
    "model/system"
    "log"
    )

    type System struct {
    tp.PullCtx
    }

    func (p *System) GetServerTime(args *system.SystemTimeArg) (reply system.SystemTime,err *tp.Rerror){

    log.Println(args.Token)

    reply = system.SystemTime{
    Time:golibs.StandardTime(),
    }
    return reply,nil
    }
    client 端
    var (
    cli *micro.Client
    rerr *tp.Rerror
    )

    func init() {
    tp.SetLoggerLevel("OFF")
    cli = micro.NewClient(
    micro.CliConfig{},
    micro.NewStaticLinker(":6666"),
    )
    }

    func main() {
    for i := 0; i < 10; i++ {
    go func(i int) {
    execute(i)
    }(i)
    }

    time.Sleep(math.MaxInt64)
    }

    func execute(i int) {
    var reply system.SystemTime
    rerr = cli.Pull("/system/get_server_time", &system.SystemTimeArg{
    Token: "sdasdasdasd",
    }, &reply).Rerror()
    if rerr != nil {
    log.Fatalf("线程%d出错:%v", i, rerr)
    }
    log.Printf("跑了第%d轮", i)
    log.Print(reply.Time)

    }
  • 相关阅读:
    hdu2049.java
    java输入输出流小细节
    滚动字幕
    hdu4504java
    HDU2054JAVA
    hdu2058java
    hdu2073递推题
    [转]SELinux管理与配置
    Can't connect to MySQL server on 'XXX' (13)
    CentOS6.5+php5.3听云安装过程
  • 原文地址:https://www.cnblogs.com/jackey2015/p/9437232.html
Copyright © 2011-2022 走看看