zpt::redis::ZList::ZList(zpt::json _options, std::string _conf_path) : __options(_options), __conn(nullptr) { try { std::string _bind((std::string)_options->getPath(_conf_path)["bind"]); std::string _address(_bind.substr(0, _bind.find(":"))); uint _port = std::stoi(_bind.substr(_bind.find(":") + 1)); this->connection(_options->getPath(_conf_path) + zpt::json{"host", _address, "port", _port}); } catch (std::exception& _e) { assertz(false, std::string("could not connect to Redis server: ") + _e.what(), 500, 0); } }
/* operand */ static int _operand(State * state) /* value | address */ { #ifdef DEBUG fprintf(stderr, "DEBUG: %s()\n", __func__); #endif if(_parser_in_set(state, TS_VALUE)) return _value(state); else if(_parser_in_set(state, TS_ADDRESS)) return _address(state); return _parser_error(state, "%s", "Expected value or address"); }
Address::Address(struct sockaddr_in address) { _address(inet_ntoa(address.sin_addr), address.sin_port); }
Address::Address(Ip ip, Port port) { _address(ip, port); }
Address::Address(Port port) { _address("0.0.0.0", port); }
Address::Address() { _address("0.0.0.0", 0); }