diff options
author | Adam <Adam@anope.org> | 2013-05-17 23:04:18 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2013-05-17 23:04:18 -0400 |
commit | 2428264315868f0860f9747c8b005536e5442db6 (patch) | |
tree | 9cd3070f46823ea5f5af32abf84d3c39975e9634 /include | |
parent | cc4a14b0badfe3d617ec2dd230d7921f8650a069 (diff) |
Add Redis database support
Diffstat (limited to 'include')
-rw-r--r-- | include/modules.h | 2 | ||||
-rw-r--r-- | include/modules/redis.h | 62 | ||||
-rw-r--r-- | include/serialize.h | 7 | ||||
-rw-r--r-- | include/sockets.h | 4 |
4 files changed, 68 insertions, 7 deletions
diff --git a/include/modules.h b/include/modules.h index 5585e9e77..31b09c2cf 100644 --- a/include/modules.h +++ b/include/modules.h @@ -368,7 +368,7 @@ class CoreExport Module : public Extensible virtual EventReturn OnSaveDatabase() { return EVENT_CONTINUE; } /** Called when the databases are loaded - * @return EVENT_CONTINUE to let other modules continue saving, EVENT_STOP to stop + * @return EVENT_CONTINUE to let other modules continue loading, EVENT_STOP to stop */ virtual EventReturn OnLoadDatabase() { return EVENT_CONTINUE; } diff --git a/include/modules/redis.h b/include/modules/redis.h new file mode 100644 index 000000000..4b321a608 --- /dev/null +++ b/include/modules/redis.h @@ -0,0 +1,62 @@ +/* + * + * (C) 2003-2013 Anope Team + * Contact us at team@anope.org + * + * Please read COPYING and README for further details. + * + */ + +namespace Redis +{ + struct Reply + { + enum Type + { + NOT_PARSED, + ERROR, + OK, + INT, + BULK, + MULTI_BULK + } + type; + + Reply() { Clear(); } + void Clear() { type = NOT_PARSED; i = 0; bulk.clear(); multi_bulk_size = 0; multi_bulk.clear(); } + + int64_t i; + Anope::string bulk; + int multi_bulk_size; + std::deque<Reply> multi_bulk; + }; + + class Interface + { + public: + Module *owner; + + Interface(Module *m) : owner(m) { } + + virtual void OnResult(const Reply &r) = 0; + virtual void OnError(const Anope::string &error) { Log(owner) << error; } + }; + + class Provider : public Service + { + public: + Provider(Module *c, const Anope::string &n) : Service(c, "Redis::Provider", n) { } + + virtual void SendCommand(Interface *i, const std::vector<Anope::string> &cmds) = 0; + virtual void SendCommand(Interface *i, const Anope::string &str) = 0; + + virtual bool BlockAndProcess() = 0; + + virtual void Subscribe(Interface *i, const Anope::string &pattern) = 0; + virtual void Unsubscribe(const Anope::string &pattern) = 0; + + virtual void StartTransaction() = 0; + virtual void CommitTransaction() = 0; + }; +} + diff --git a/include/serialize.h b/include/serialize.h index a43046b1e..472701932 100644 --- a/include/serialize.h +++ b/include/serialize.h @@ -80,7 +80,10 @@ class CoreExport Serializable : public virtual Base virtual ~Serializable(); /* Unique ID (per type, not globally) for this object */ - unsigned int id; + uint64_t id; + + /* Only used by redis, to ignore updates */ + unsigned short redis_ignore; /** Marks the object as potentially being updated "soon". */ @@ -129,7 +132,7 @@ class CoreExport Serialize::Type public: /* Map of Serializable::id to Serializable objects */ - std::map<unsigned int, Serializable *> objects; + std::map<uint64_t, Serializable *> objects; /** Creates a new serializable type * @param n Type name diff --git a/include/sockets.h b/include/sockets.h index 8b1abe5c2..8b7b78a7f 100644 --- a/include/sockets.h +++ b/include/sockets.h @@ -388,10 +388,6 @@ class CoreExport ConnectionSocket : public virtual Socket /* Sockaddrs for connection ip/port */ sockaddrs conaddr; - /** Constructor - */ - ConnectionSocket(); - /** Connect the socket * @param TargetHost The target host to connect to * @param Port The target port to connect to |