CouchDbContext(CouchDbClientBase dbc, CouchDbProperties props) { this.dbc = dbc; if (props.isCreateDbIfNotExist()) { createDB(props.getDbName()); } else { serverVersion(); // pre warm up client } }
void initChanges() { String since = endpoint.getSince(); if (since == null) { CouchDbInfo dbInfo = couchClient.context().info(); since = dbInfo.getUpdateSeq(); // get latest update seq LOG.debug("Last sequence [{}]", since); } changes = couchClient.changes().style(endpoint.getStyle()).includeDocs(true) .since(since).heartBeat(endpoint.getHeartbeat()).continuousChanges(); }
CouchDbClientBase(CouchDbConfig config) { final CouchDbProperties props = config.getProperties(); this.httpClient = createHttpClient(props); this.gson = initGson(new GsonBuilder()); this.host = new HttpHost(props.getHost(), props.getPort(), props.getProtocol()); final String path = props.getPath() != null ? props.getPath() : ""; this.baseURI = buildUri().scheme(props.getProtocol()).host(props.getHost()).port(props.getPort()).path("/").path(path).build(); this.dbURI = buildUri(baseURI).path(props.getDbName()).path("/").build(); this.context = new CouchDbContext(this, props); this.design = new CouchDbDesign(this); }