Kinetic C/C++ Client
 All Classes Functions Variables Pages
nonblocking_packet_service_interface.h
1 /*
2  * kinetic-cpp-client
3  * Copyright (C) 2014 Seagate Technology.
4  *
5  * This program is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU General Public License
7  * as published by the Free Software Foundation; either version 2
8  * of the License, or (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  *
19  */
20 
21 #ifndef KINETIC_CPP_CLIENT_NONBLOCKING_PACKET_SERVICE_INTERFACE_H_
22 #define KINETIC_CPP_CLIENT_NONBLOCKING_PACKET_SERVICE_INTERFACE_H_
23 
24 #include <sys/select.h>
25 #include <memory>
26 
27 #include "kinetic/kinetic_status.h"
28 #include "kinetic_client.pb.h"
29 
30 namespace kinetic {
31 
32 using com::seagate::kinetic::client::proto::Message;
33 using com::seagate::kinetic::client::proto::Command;
34 
35 using std::shared_ptr;
36 using std::unique_ptr;
37 using std::string;
38 
39 typedef uint64_t HandlerKey;
40 
41 // Instances of this cannot be re-used for multiple requests as they are deleted after processing.
43  public:
44  virtual ~HandlerInterface() {}
45 
46  // response is re-used, so make sure to copy everything you need out of it
47  virtual void Handle(const Command &response, unique_ptr<const string> value) = 0;
48  virtual void Error(KineticStatus error, Command const * const response) = 0;
49 };
50 
52  public:
54  // message is modified in this call hierarchy
55  virtual HandlerKey Submit(unique_ptr<Message> message, unique_ptr<Command> command, const shared_ptr<const string> value,
56  unique_ptr<HandlerInterface> handler) = 0;
57  virtual bool Run(fd_set *read_fds, fd_set *write_fds, int *nfds) = 0;
58  virtual bool Remove(HandlerKey handler_key) = 0;
59 };
60 
61 } // namespace kinetic
62 
63 #endif // KINETIC_CPP_CLIENT_NONBLOCKING_PACKET_SERVICE_INTERFACE_H_
Indicates whether a Kinetic operation (get, put, security, etc) put succeeded or failed. Unlike Status it provides details like whether the failure resulted from a version or an HMAC error.