Skip to content

Commit 0f1bbce

Browse files
authored
Merge pull request #1774 from Barenboim/master
Add task 'const' interfaces.
2 parents e06e123 + 94dd3a6 commit 0f1bbce

File tree

7 files changed

+44
-5
lines changed

7 files changed

+44
-5
lines changed

src/client/WFConsulClient.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ static bool parse_list_service_result(const json_value_t *root,
7171
std::vector<struct ConsulServiceTags>& result);
7272

7373
bool WFConsulTask::get_discover_result(
74-
std::vector<struct ConsulServiceInstance>& result)
74+
std::vector<struct ConsulServiceInstance>& result) const
7575
{
7676
json_value_t *root;
7777
int errno_bak;
@@ -99,7 +99,7 @@ bool WFConsulTask::get_discover_result(
9999
}
100100

101101
bool WFConsulTask::get_list_service_result(
102-
std::vector<struct ConsulServiceTags>& result)
102+
std::vector<struct ConsulServiceTags>& result) const
103103
{
104104
json_value_t *root;
105105
int errno_bak;

src/client/WFConsulClient.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ class WFConsulTask : public WFGenericTask
4444
{
4545
public:
4646
bool get_discover_result(
47-
std::vector<struct protocol::ConsulServiceInstance>& result);
47+
std::vector<struct protocol::ConsulServiceInstance>& result) const;
4848

4949
bool get_list_service_result(
50-
std::vector<struct protocol::ConsulServiceTags>& result);
50+
std::vector<struct protocol::ConsulServiceTags>& result) const;
5151

5252
public:
5353
void set_service(const struct protocol::ConsulService *service);
@@ -71,6 +71,7 @@ class WFConsulTask : public WFGenericTask
7171
{
7272
this->consul_index = consul_index;
7373
}
74+
7475
long long get_consul_index() const { return this->consul_index; }
7576

7677
const protocol::HttpResponse *get_http_resp() const

src/client/WFHttpChunkedClient.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ class WFHttpChunkedTask : public WFGenericTask
3434
return this->chunk;
3535
}
3636

37+
const protocol::HttpMessageChunk *get_chunk() const
38+
{
39+
return this->chunk;
40+
}
41+
3742
public:
3843
protocol::HttpRequest *get_req()
3944
{
@@ -45,6 +50,16 @@ class WFHttpChunkedTask : public WFGenericTask
4550
return this->task->get_resp();
4651
}
4752

53+
const protocol::HttpRequest *get_req() const
54+
{
55+
return this->task->get_req();
56+
}
57+
58+
const protocol::HttpResponse *get_resp() const
59+
{
60+
return this->task->get_resp();
61+
}
62+
4863
public:
4964
void set_watch_timeout(int timeout)
5065
{

src/client/WFKafkaClient.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,3 +1692,8 @@ KafkaMetaList *WFKafkaClient::get_meta_list()
16921692
return &this->member->meta_list;
16931693
}
16941694

1695+
const KafkaMetaList *WFKafkaClient::get_meta_list() const
1696+
{
1697+
return &this->member->meta_list;
1698+
}
1699+

src/client/WFKafkaClient.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,11 @@ class WFKafkaTask : public WFGenericTask
101101
return &this->result;
102102
}
103103

104+
const protocol::KafkaResult *get_result() const
105+
{
106+
return &this->result;
107+
}
108+
104109
int get_kafka_error() const
105110
{
106111
return this->kafka_error;
@@ -183,7 +188,7 @@ class WFKafkaClient
183188
public:
184189
protocol::KafkaMetaList *get_meta_list();
185190

186-
protocol::KafkaBrokerList *get_broker_list();
191+
const protocol::KafkaMetaList *get_meta_list() const;
187192

188193
private:
189194
class KafkaMember *member;

src/client/WFRedisSubscriber.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@ class WFRedisSubscribeTask : public WFGenericTask
4141
return this->task->get_resp();
4242
}
4343

44+
const protocol::RedisResponse *get_resp() const
45+
{
46+
return this->task->get_resp();
47+
}
48+
4449
public:
4550
/* User needs to call 'release()' exactly once, anywhere. */
4651
void release()

src/factory/WFTask.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ class WFThreadTask : public ExecRequest
6868
INPUT *get_input() { return &this->input; }
6969
OUTPUT *get_output() { return &this->output; }
7070

71+
const INPUT *get_input() const { return &this->input; }
72+
const OUTPUT *get_output() const { return &this->output; }
73+
7174
public:
7275
void *user_data;
7376

@@ -134,6 +137,9 @@ class WFNetworkTask : public CommRequest
134137
REQ *get_req() { return &this->req; }
135138
RESP *get_resp() { return &this->resp; }
136139

140+
const REQ *get_req() const { return &this->req; }
141+
const RESP *get_resp() const { return &this->resp; }
142+
137143
public:
138144
void *user_data;
139145

@@ -332,6 +338,8 @@ class WFFileTask : public IORequest
332338
public:
333339
ARGS *get_args() { return &this->args; }
334340

341+
const ARGS *get_args() const { return &this->args; }
342+
335343
long get_retval() const
336344
{
337345
if (this->state == WFT_STATE_SUCCESS)

0 commit comments

Comments
 (0)