2019-07-28 10:31:56 +08:00
|
|
|
|
#pragma once
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../acl_cpp_define.hpp"
|
2015-05-06 17:16:10 +08:00
|
|
|
|
#include <vector>
|
2019-05-09 13:57:51 +08:00
|
|
|
|
#include "../stdlib/noncopyable.hpp"
|
2017-06-02 14:47:24 +08:00
|
|
|
|
#include "../stdlib/string.hpp"
|
2015-05-06 17:16:10 +08:00
|
|
|
|
|
2019-05-18 21:19:21 +08:00
|
|
|
|
#ifndef ACL_CLIENT_ONLY
|
|
|
|
|
|
2015-05-06 17:16:10 +08:00
|
|
|
|
namespace acl
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
class redis_result;
|
|
|
|
|
|
2015-09-08 17:21:04 +08:00
|
|
|
|
/**
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD>ڴ<EFBFBD> disque <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD>õ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-09-08 17:21:04 +08:00
|
|
|
|
*/
|
2019-05-09 13:57:51 +08:00
|
|
|
|
class ACL_CPP_API disque_job : public noncopyable
|
2015-05-06 17:16:10 +08:00
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
disque_job();
|
|
|
|
|
~disque_job();
|
|
|
|
|
|
2015-09-08 17:21:04 +08:00
|
|
|
|
/**
|
|
|
|
|
* get the ID of the job
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ID <EFBFBD><EFBFBD>
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* @return {const char*}
|
|
|
|
|
*/
|
2015-05-06 17:16:10 +08:00
|
|
|
|
const char* get_id() const
|
|
|
|
|
{
|
|
|
|
|
return id_.c_str();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 17:21:04 +08:00
|
|
|
|
/**
|
|
|
|
|
* get the queue name holding the job
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڵĶ<EFBFBD><EFBFBD><EFBFBD>
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* @return {const char*}
|
|
|
|
|
*/
|
2015-05-06 17:16:10 +08:00
|
|
|
|
const char* get_queue() const
|
|
|
|
|
{
|
|
|
|
|
return queue_.c_str();
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-08 17:21:04 +08:00
|
|
|
|
/**
|
|
|
|
|
* get the job's data
|
2019-07-28 10:31:56 +08:00
|
|
|
|
* <EFBFBD><EFBFBD><EFBFBD>õ<EFBFBD>ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
2015-09-08 17:21:04 +08:00
|
|
|
|
* @return {const string&}
|
|
|
|
|
*/
|
2015-05-06 17:16:10 +08:00
|
|
|
|
const string& get_body() const
|
|
|
|
|
{
|
|
|
|
|
return body_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void set_id(const char* id);
|
|
|
|
|
void set_queue(const char* name);
|
|
|
|
|
void set_body(const char* job, size_t len);
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
bool init(const redis_result& rr);
|
|
|
|
|
|
|
|
|
|
const char* get_state() const
|
|
|
|
|
{
|
|
|
|
|
return state_.c_str();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_repl() const
|
|
|
|
|
{
|
|
|
|
|
return repl_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_ttl() const
|
|
|
|
|
{
|
|
|
|
|
return ttl_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
long long int get_ctime() const
|
|
|
|
|
{
|
|
|
|
|
return ctime_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_delay() const
|
|
|
|
|
{
|
|
|
|
|
return delay_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_retry() const
|
|
|
|
|
{
|
|
|
|
|
return retry_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::vector<string>& get_nodes_delivered() const
|
|
|
|
|
{
|
|
|
|
|
return nodes_delivered_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const std::vector<string>& get_nodes_confirmed() const
|
|
|
|
|
{
|
|
|
|
|
return nodes_confirmed_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_next_requeue_within() const
|
|
|
|
|
{
|
|
|
|
|
return next_requeue_within_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_next_awake_within() const
|
|
|
|
|
{
|
|
|
|
|
return next_awake_within_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
string id_;
|
|
|
|
|
string queue_;
|
|
|
|
|
string state_;
|
|
|
|
|
int repl_;
|
|
|
|
|
int ttl_;
|
|
|
|
|
long long int ctime_;
|
|
|
|
|
int delay_;
|
|
|
|
|
int retry_;
|
|
|
|
|
std::vector<string> nodes_delivered_;
|
|
|
|
|
std::vector<string> nodes_confirmed_;
|
|
|
|
|
int next_requeue_within_;
|
|
|
|
|
int next_awake_within_;
|
|
|
|
|
string body_;
|
|
|
|
|
|
|
|
|
|
void set_nodes_delivered(const redis_result& rr);
|
|
|
|
|
void set_nodes_confirmed(const redis_result& rr);
|
|
|
|
|
void set_nodes(const redis_result& rr, std::vector<string>& out);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace acl
|
2019-05-18 21:19:21 +08:00
|
|
|
|
|
|
|
|
|
#endif // ACL_CLIENT_ONLY
|