Skip to content

Commit

Permalink
correct naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Hellblazer committed Feb 18, 2024
1 parent 7f4e26b commit a30c68c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,67 +6,56 @@
*/
package com.salesforce.apollo.archipelago;

import java.time.Duration;
import java.util.function.Function;

import com.salesforce.apollo.archipelago.RouterImpl.CommonCommunications;
import com.salesforce.apollo.archipelago.ServerConnectionCache.CreateClientCommunications;
import com.salesforce.apollo.cryptography.Digest;
import com.salesforce.apollo.membership.Member;
import com.salesforce.apollo.protocols.ClientIdentity;

import io.grpc.BindableService;
import io.grpc.Context;
import io.grpc.Metadata;

import java.time.Duration;
import java.util.function.Function;

/**
* @author hal.hildebrand
*
*/
public interface Router {

@FunctionalInterface
interface ClientConnector<Client> {
Client connect(Member to);
}

interface ServiceRouting {
default String routing() {
return getClass().getCanonicalName();
}
}

String COM_SALESFORCE_APOLLO_ARCHIPELIGO_AGENT_ID = "agent.id";
String COM_SALESFORCE_APOLLO_ARCHIPELIGO_AGENT_ID_SERVER = "agent.id.server";
String COM_SALESFORCE_APOLLO_ARCHIPELIGO_CONTEXT_ID = "context.id";
String COM_SALESFORCE_APOLLO_ARCHIPELIGO_CONTEXT_ID_SERVER = "context.id.server";
String COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID = "from.id";
String COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID_CLIENT = "from.id.client";
String COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID_SERVER = "from.id.server";
String COM_SALESFORCE_APOLLO_ARCHIPELIGO_TO_ID = "to.id";
String COM_SALESFORCE_APOLLO_ARCHIPELIGO_TO_ID_SERVER = "to.id.server";
Context.Key<Digest> CLIENT_CLIENT_ID_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID_CLIENT);
Metadata.Key<String> METADATA_AGENT_KEY = Metadata.Key.of(COM_SALESFORCE_APOLLO_ARCHIPELIGO_AGENT_ID,
Metadata.ASCII_STRING_MARSHALLER);
Metadata.Key<String> METADATA_CLIENT_ID_KEY = Metadata.Key.of(COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID,
Metadata.ASCII_STRING_MARSHALLER);
Metadata.Key<String> METADATA_CONTEXT_KEY = Metadata.Key.of(COM_SALESFORCE_APOLLO_ARCHIPELIGO_CONTEXT_ID,
Metadata.ASCII_STRING_MARSHALLER);
Metadata.Key<String> METADATA_TARGET_KEY = Metadata.Key.of(COM_SALESFORCE_APOLLO_ARCHIPELIGO_TO_ID,
Metadata.ASCII_STRING_MARSHALLER);
Context.Key<Digest> SERVER_AGENT_ID_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_AGENT_ID_SERVER);
Context.Key<Digest> SERVER_CLIENT_ID_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_FROM_ID_SERVER);
Context.Key<Digest> SERVER_CONTEXT_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_CONTEXT_ID_SERVER);
Context.Key<Digest> SERVER_TARGET_KEY = Context.key(COM_SALESFORCE_APOLLO_ARCHIPELIGO_TO_ID_SERVER);
String COM_SALESFORCE_APOLLO_ARCHIPELAGO_AGENT_ID = "agent.id";
String COM_SALESFORCE_APOLLO_ARCHIPELAGO_AGENT_ID_SERVER = "agent.id.server";
String COM_SALESFORCE_APOLLO_ARCHIPELAGO_CONTEXT_ID = "context.id";
String COM_SALESFORCE_APOLLO_ARCHIPELAGO_CONTEXT_ID_SERVER = "context.id.server";
String COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID = "from.id";
String COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID_CLIENT = "from.id.client";
String COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID_SERVER = "from.id.server";
String COM_SALESFORCE_APOLLO_ARCHIPELAGO_TO_ID = "to.id";
String COM_SALESFORCE_APOLLO_ARCHIPELAGO_TO_ID_SERVER = "to.id.server";
Context.Key<Digest> CLIENT_CLIENT_ID_KEY = Context.key(
COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID_CLIENT);
Metadata.Key<String> METADATA_AGENT_KEY = Metadata.Key.of(
COM_SALESFORCE_APOLLO_ARCHIPELAGO_AGENT_ID, Metadata.ASCII_STRING_MARSHALLER);
Metadata.Key<String> METADATA_CLIENT_ID_KEY = Metadata.Key.of(
COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID, Metadata.ASCII_STRING_MARSHALLER);
Metadata.Key<String> METADATA_CONTEXT_KEY = Metadata.Key.of(
COM_SALESFORCE_APOLLO_ARCHIPELAGO_CONTEXT_ID, Metadata.ASCII_STRING_MARSHALLER);
Metadata.Key<String> METADATA_TARGET_KEY = Metadata.Key.of(
COM_SALESFORCE_APOLLO_ARCHIPELAGO_TO_ID, Metadata.ASCII_STRING_MARSHALLER);
Context.Key<Digest> SERVER_AGENT_ID_KEY = Context.key(
COM_SALESFORCE_APOLLO_ARCHIPELAGO_AGENT_ID_SERVER);
Context.Key<Digest> SERVER_CLIENT_ID_KEY = Context.key(
COM_SALESFORCE_APOLLO_ARCHIPELAGO_FROM_ID_SERVER);
Context.Key<Digest> SERVER_CONTEXT_KEY = Context.key(
COM_SALESFORCE_APOLLO_ARCHIPELAGO_CONTEXT_ID_SERVER);
Context.Key<Digest> SERVER_TARGET_KEY = Context.key(
COM_SALESFORCE_APOLLO_ARCHIPELAGO_TO_ID_SERVER);

void close(Duration await);

<Client extends Link, Service extends Router.ServiceRouting> CommonCommunications<Client, Service> create(Member member,
Digest context,
Service service,
Function<RoutableService<Service>, BindableService> factory,
CreateClientCommunications<Client> createFunction,
Client localLoopback);
<Client extends Link, Service extends Router.ServiceRouting> CommonCommunications<Client, Service> create(
Member member, Digest context, Service service, Function<RoutableService<Service>, BindableService> factory,
CreateClientCommunications<Client> createFunction, Client localLoopback);

<Service, Client extends Link> CommonCommunications<Client, Service> create(Member member, Digest context,
Service service, String routingLabel,
Expand All @@ -84,4 +73,15 @@ <Client extends Link, Service> CommonCommunications<Client, Service> create(Memb

void start();

@FunctionalInterface
interface ClientConnector<Client> {
Client connect(Member to);
}

interface ServiceRouting {
default String routing() {
return getClass().getCanonicalName();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.salesforce.apollo.archipeligo;
package com.salesforce.apollo.archipelago;

import com.google.common.primitives.Ints;
import com.google.protobuf.Any;
import com.google.protobuf.ByteString;
import com.salesforce.apollo.archipelago.Demultiplexer;
import com.salesforce.apollo.archipelago.Router;
import com.salesforce.apollo.comm.grpc.DomainSocketServerInterceptor;
import com.salesforce.apollo.cryptography.DigestAlgorithm;
import com.salesforce.apollo.test.proto.ByteMessage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.salesforce.apollo.archipeligo;
package com.salesforce.apollo.archipelago;

import com.google.protobuf.Any;
import com.google.protobuf.ByteString;
import com.salesforce.apollo.archipelago.*;
import com.salesforce.apollo.archipelago.RouterImpl.CommonCommunications;
import com.salesforce.apollo.comm.grpc.DomainSocketServerInterceptor;
import com.salesforce.apollo.cryptography.DigestAlgorithm;
Expand Down Expand Up @@ -157,11 +156,11 @@ private ManagedChannel handler(DomainSocketAddress address) {
.build();
}

public static interface TestIt {
public interface TestIt {
void ping(Any request, StreamObserver<Any> responseObserver);
}

public static interface TestItService extends Link {
public interface TestItService extends Link {
Any ping(Any request);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.salesforce.apollo.archipeligo;
package com.salesforce.apollo.archipelago;

import com.google.protobuf.Any;
import com.google.protobuf.ByteString;
import com.salesforce.apollo.test.proto.ByteMessage;
import com.salesforce.apollo.test.proto.TestItGrpc;
import com.salesforce.apollo.test.proto.TestItGrpc.TestItBlockingStub;
import com.salesforce.apollo.test.proto.TestItGrpc.TestItImplBase;
import com.salesforce.apollo.archipelago.*;
import com.salesforce.apollo.archipelago.RouterImpl.CommonCommunications;
import com.salesforce.apollo.cryptography.DigestAlgorithm;
import com.salesforce.apollo.membership.Member;
import com.salesforce.apollo.membership.impl.SigningMemberImpl;
import com.salesforce.apollo.test.proto.ByteMessage;
import com.salesforce.apollo.test.proto.TestItGrpc;
import com.salesforce.apollo.test.proto.TestItGrpc.TestItBlockingStub;
import com.salesforce.apollo.test.proto.TestItGrpc.TestItImplBase;
import com.salesforce.apollo.utils.Utils;
import io.grpc.stub.StreamObserver;
import org.joou.ULong;
Expand Down Expand Up @@ -89,11 +88,11 @@ public void smokin() throws Exception {
routerB.close(Duration.ofSeconds(1));
}

public static interface TestIt {
public interface TestIt {
void ping(Any request, StreamObserver<Any> responseObserver);
}

public static interface TestItService extends Link {
public interface TestItService extends Link {
Any ping(Any request);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*/
package com.salesforce.apollo.archipeligo;
package com.salesforce.apollo.archipelago;

import com.google.protobuf.Any;
import com.google.protobuf.ByteString;
import com.salesforce.apollo.cryptography.DigestAlgorithm;
import com.salesforce.apollo.membership.Member;
import com.salesforce.apollo.membership.impl.SigningMemberImpl;
import com.salesforce.apollo.test.proto.ByteMessage;
import com.salesforce.apollo.test.proto.TestItGrpc;
import com.salesforce.apollo.test.proto.TestItGrpc.TestItBlockingStub;
import com.salesforce.apollo.test.proto.TestItGrpc.TestItImplBase;
import com.salesforce.apollo.archipelago.*;
import com.salesforce.apollo.cryptography.DigestAlgorithm;
import com.salesforce.apollo.membership.Member;
import com.salesforce.apollo.membership.impl.SigningMemberImpl;
import com.salesforce.apollo.utils.Utils;
import io.grpc.inprocess.InProcessChannelBuilder;
import io.grpc.inprocess.InProcessServerBuilder;
Expand Down Expand Up @@ -87,11 +86,11 @@ public Any ping(Any request) {
router.close(Duration.ofSeconds(1));
}

public static interface TestIt {
public interface TestIt {
void ping(Any request, StreamObserver<Any> responseObserver);
}

public static interface TestItService extends Link {
public interface TestItService extends Link {
Any ping(Any request);
}

Expand Down

0 comments on commit a30c68c

Please sign in to comment.