Search in sources :

Example 1 with KeyValueService

use of com.couchbase.client.core.service.KeyValueService in project couchbase-jvm-clients by couchbase.

the class Node method createService.

/**
 * Helper method to create the {@link Service} based on the service type provided.
 *
 * @param serviceType the type of service to create.
 * @param port the port for that service.
 * @param bucket optionally the bucket name.
 * @return a created service, but not yet connected or anything.
 */
protected Service createService(final ServiceType serviceType, final int port, final Optional<String> bucket) {
    CoreEnvironment env = ctx.environment();
    String address = alternateAddress.orElseGet(identifier::address);
    switch(serviceType) {
        case KV:
            return new KeyValueService(KeyValueServiceConfig.endpoints(env.ioConfig().numKvConnections()).build(), ctx, address, port, bucket, authenticator);
        case MANAGER:
            return new ManagerService(ctx, address, port);
        case QUERY:
            return new QueryService(QueryServiceConfig.maxEndpoints(env.ioConfig().maxHttpConnections()).idleTime(env.ioConfig().idleHttpConnectionTimeout()).build(), ctx, address, port);
        case VIEWS:
            return new ViewService(ViewServiceConfig.maxEndpoints(env.ioConfig().maxHttpConnections()).idleTime(env.ioConfig().idleHttpConnectionTimeout()).build(), ctx, address, port);
        case SEARCH:
            return new SearchService(SearchServiceConfig.maxEndpoints(env.ioConfig().maxHttpConnections()).idleTime(env.ioConfig().idleHttpConnectionTimeout()).build(), ctx, address, port);
        case ANALYTICS:
            return new AnalyticsService(AnalyticsServiceConfig.maxEndpoints(env.ioConfig().maxHttpConnections()).idleTime(env.ioConfig().idleHttpConnectionTimeout()).build(), ctx, address, port);
        case EVENTING:
            return new EventingService(ctx, address, port);
        case BACKUP:
            return new BackupService(ctx, address, port);
        default:
            throw InvalidArgumentException.fromMessage("Unsupported ServiceType: " + serviceType);
    }
}
Also used : KeyValueService(com.couchbase.client.core.service.KeyValueService) BackupService(com.couchbase.client.core.service.BackupService) CoreEnvironment(com.couchbase.client.core.env.CoreEnvironment) QueryService(com.couchbase.client.core.service.QueryService) SearchService(com.couchbase.client.core.service.SearchService) ViewService(com.couchbase.client.core.service.ViewService) AnalyticsService(com.couchbase.client.core.service.AnalyticsService) ManagerService(com.couchbase.client.core.service.ManagerService) EventingService(com.couchbase.client.core.service.EventingService)

Aggregations

CoreEnvironment (com.couchbase.client.core.env.CoreEnvironment)1 AnalyticsService (com.couchbase.client.core.service.AnalyticsService)1 BackupService (com.couchbase.client.core.service.BackupService)1 EventingService (com.couchbase.client.core.service.EventingService)1 KeyValueService (com.couchbase.client.core.service.KeyValueService)1 ManagerService (com.couchbase.client.core.service.ManagerService)1 QueryService (com.couchbase.client.core.service.QueryService)1 SearchService (com.couchbase.client.core.service.SearchService)1 ViewService (com.couchbase.client.core.service.ViewService)1