Kyoto Tycoon

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions
kyototycoon::RPCServer Class Reference

RPC server. More...

`#include <ktrpc.h>`

List of all members.

## Classes
class | Logger
| Interface to log internal information and errors. More...
class | Session
| Interface to log internal information and errors. More...
class | Worker
| Interface to process each request. More...
class | WorkerAdapter
| Adapter for the worker.
## Public Member Functions
| RPCServer ()
| Default constructor.
| ~RPCServer ()
| Destructor.
void | set_network (const std::string &expr, double timeout=-1)
| Set the network configurations.
void | set_logger (Logger *logger, uint32_t kinds=Logger::SYSTEM|Logger::ERROR)
| Set the logger to process each log message.
void | set_worker (Worker *worker, size_t thnum=1)
| Set the worker to process each request.
bool | start ()
| Start the service.
bool | stop ()
| Stop the service.
bool | finish ()
| Finish the service.
void | log (Logger::Kind kind, const char *format,...)
| Log a message.
void | log_v (Logger::Kind kind, const char *format, va_list ap)
| Log a message.
HTTPServer * | reveal_core ()
| Reveal the internal HTTP server.

## Detailed Description

RPC server.

## Constructor & Destructor Documentation

kyototycoon::RPCServer::RPCServer | ( |  | ) | `[explicit]`

Default constructor.

kyototycoon::RPCServer::~RPCServer | ( |  | ) |

Destructor.

## Member Function Documentation

void kyototycoon::RPCServer::set_network | ( | const std::string & | expr,
|  | double | timeout = `-1`
| ) |  |

Set the network configurations.

Parameters:

  expr | an expression of the address and the port of the server.
  timeout | the timeout of each network operation in seconds. If it is not more than 0, no timeout is specified.

void kyototycoon::RPCServer::set_logger | ( | Logger * | logger,
|  | uint32_t | kinds = `Logger::SYSTEM | Logger::ERROR`
| ) |  |

Set the logger to process each log message.

Parameters:

  logger | the logger object.
  kinds | kinds of logged messages by bitwise-or: Logger::DEBUG for debugging, Logger::INFO for normal information, Logger::SYSTEM for system information, and Logger::ERROR for fatal error.

void kyototycoon::RPCServer::set_worker | ( | Worker * | worker,
|  | size_t | thnum = `1`
| ) |  |

Set the worker to process each request.

Parameters:

  worker | the worker object.
  thnum | the number of worker threads.

bool kyototycoon::RPCServer::start | ( |  | ) |

Start the service.

Returns:
  true on success, or false on failure.

Note:
  This function blocks until the server stops by the RPCServer::stop method.

bool kyototycoon::RPCServer::stop | ( |  | ) |

Stop the service.

Returns:
  true on success, or false on failure.

bool kyototycoon::RPCServer::finish | ( |  | ) |

Finish the service.

Returns:
  true on success, or false on failure.

void kyototycoon::RPCServer::log | ( | Logger::Kind | kind,
|  | const char * | format,
|  |  | ...
| ) |  |

Log a message.

Parameters:

  kind | the kind of the event. Logger::DEBUG for debugging, Logger::INFO for normal information, Logger::SYSTEM for system information, and Logger::ERROR for fatal error.
  format | the printf-like format string. The conversion character `' can be used with such flag characters as `s', `d', `o', `u', `x', `X', `c', `e', `E', `f', `g', `G', and `'.
  ... | used according to the format string.

void kyototycoon::RPCServer::log_v | ( | Logger::Kind | kind,
|  | const char * | format,
|  | va_list | ap
| ) |  |

Log a message.

Note:
  Equal to the original Cursor::set_value method except that the last parameters is va_list.

HTTPServer* kyototycoon::RPCServer::reveal_core | ( |  | ) |

Reveal the internal HTTP server.

Returns:
  the internal HTTP server.