Example #1
0
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
}
Example #2
0
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
}