Skip to content

notedit/bsonrpc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bsonrpc

a rpc from http://code.google.com/p/vitess/

go rpc server:

package main

import (
    "net/rpc"
    "bsonrpc"
)


type Args struct {
    A, B int 
}

type Reply struct {
    C int 
}

type Arith int 


func (t *Arith) Add(args *Args, reply *Reply) error {
    reply.C = args.A + args.B
    return nil 
}

func (t *Arith) Mul(args *Args, reply *Reply) error {
    reply.C = args.A * args.B
    return nil 
}

func (t *Arith) NError(args *Args, reply *Reply) error {
    return errors.New("normalerror")
}

func main(){
    rpc.Register(new(Arith))
    bsonrpc.ListenAndServe("localhost:9999")
}

python rpc client

import bsonrpc                                                                  

addr = 'localhost:9999'
uri = 'http://%s/_bson_rpc_' % addr

client = bsonrpc.BsonRpcClient(uri,5.0)

reply = client.call('Arith.Add',{'A':7,'B':8})

print reply.sequence_id,reply.reply

reply = client.call('Arith.Mul',{'A':4,'B':8})

print reply.sequence_id,reply.reply

Releases

No releases published

Packages

No packages published