All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.activej.crdt.storage.cluster.IDiscoveryService Maven / Gradle / Ivy

The newest version!
/*
 * Copyright (C) 2020 ActiveJ LLC.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.activej.crdt.storage.cluster;

import io.activej.async.function.AsyncSupplier;
import io.activej.common.annotation.ComponentInterface;
import io.activej.crdt.storage.ICrdtStorage;
import io.activej.promise.Promise;
import io.activej.promise.SettablePromise;
import io.activej.rpc.client.sender.strategy.RpcStrategy;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.function.Function;

@ComponentInterface
public interface IDiscoveryService

{ AsyncSupplier> discover(); interface PartitionScheme

{ Set

getPartitions(); ICrdtStorage provideCrdtConnection(P partition); RpcStrategy provideRpcConnection(P partition); > @Nullable Sharder createSharder(List

alive); > RpcStrategy createRpcStrategy(Function keyGetter); boolean isReadValid(Collection

alive); } static

IDiscoveryService

of(PartitionScheme

partitionScheme) { return () -> new AsyncSupplier<>() { int i = 0; @Override public Promise> get() { return i++ == 0 ? Promise.of(partitionScheme) : new SettablePromise<>(); } }; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy