blob: 910c4478c227cbf97fa01670dd25503bbee65ff2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once
#include <cstdint>
class FRT_RPCRequest;
namespace storage {
/**
* This event wraps a request received from a remote rpc client.
**/
class RPCRequestWrapper {
public:
enum ErrorCode {
ERR_HANDLE_NOT_CONNECTED = 75000, // > 0xffff
ERR_HANDLE_GONE = 75001,
ERR_REQUEST_DELETED = 75002,
ERR_HANDLE_DISABLED = 75003,
ERR_NODE_SHUTTING_DOWN = 75004,
ERR_BAD_REQUEST = 75005
};
RPCRequestWrapper(FRT_RPCRequest *req);
~RPCRequestWrapper();
/**
* @return request parameter data
**/
const char *getParam() const;
/**
* @return request parameter length
**/
uint32_t getParamLen() const;
/**
* Return data for this request.
*
* @param pt return data
* @param len return data length
**/
void returnData(const char *pt, uint32_t len);
/**
* Return an error for this request
*
* @param errorCode numeric error code
* @param errorMessage human readable error message
**/
void returnError(uint32_t errorCode, const char *errorMessage);
FRT_RPCRequest* raw_request() noexcept { return _req; }
const char *getMethodName() const;
void addReturnString(const char *str, uint32_t len=0);
void addReturnInt(uint32_t value);
void returnRequest();
/**
* Discard any large blobs from the underlying rpc request. This
* may be done after interpreting any parameters in order to save
* memory on the server.
**/
void discardBlobs();
private:
RPCRequestWrapper(const RPCRequestWrapper &);
RPCRequestWrapper &operator=(const RPCRequestWrapper &);
FRT_RPCRequest* _req; // underlying RPC request
};
} // namespace storage
|