forked from deepfryed/beanstalk-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeanstalk.hpp
65 lines (61 loc) · 2.04 KB
/
beanstalk.hpp
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
#pragma once
#include "beanstalk.h"
#include <string>
#include <vector>
#include <map>
namespace Beanstalk {
typedef std::vector<std::string> info_list_t;
typedef std::map<std::string, std::string> info_hash_t;
class Job {
public:
int id();
std::string& body();
Job(int, char*, size_t);
Job(BSJ*);
Job();
operator bool() { return _id > 0; }
protected:
int _id;
std::string _body;
};
class Client {
public:
~Client();
Client();
Client(std::string host, int port, float timeout_secs = 0);
bool ping();
bool use(std::string);
bool watch(std::string);
bool ignore(std::string);
int put(std::string, int priority = 0, int delay = 0, int ttr = 60);
int put(char *data, size_t bytes, int priority, int delay, int ttr);
bool del(int id);
bool del(Job&);
bool reserve(Job &);
bool reserve(Job &, int timeout);
bool release(Job &, int priority = 1, int delay = 0);
bool release(int id, int priority = 1, int delay = 0);
bool bury(Job &, int priority = 1);
bool bury(int id, int priority = 1);
bool touch(Job &);
bool touch(int id);
bool peek(Job &, int id);
bool peek_ready(Job &);
bool peek_delayed(Job &);
bool peek_buried(Job &);
bool kick(int bound);
void connect(std::string host, int port, float timeout_secs = 0);
void reconnect();
bool disconnect();
std::string list_tube_used();
info_list_t list_tubes();
info_list_t list_tubes_watched();
info_hash_t stats();
info_hash_t stats_job(int);
info_hash_t stats_tube(std::string);
protected:
float timeout_secs;
int handle, port;
std::string host;
};
}