示例#1
0
文件: main.go 项目: yarpc/yarpc-go
func set(ctx context.Context, c json.Client, k string, v string) error {
	var response setResponse
	ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
	defer cancel()
	_, err := c.Call(
		ctx,
		yarpc.NewReqMeta().Procedure("set"),
		&setRequest{Key: k, Value: v},
		&response,
	)
	return err
}
示例#2
0
文件: main.go 项目: yarpc/yarpc-go
func get(ctx context.Context, c json.Client, k string) (string, error) {
	var response getResponse
	ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond)
	defer cancel()
	_, err := c.Call(
		ctx,
		yarpc.NewReqMeta().Procedure("get"),
		&getRequest{Key: k},
		&response,
	)
	return response.Value, err
}