Skip to content

Commit

Permalink
Added more classes to api.auth package, removed dep on slf4j-api from…
Browse files Browse the repository at this point in the history
… services-api
  • Loading branch information
artem-v committed Sep 28, 2024
1 parent f56e900 commit 775ee5c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 27 deletions.
4 changes: 0 additions & 4 deletions services-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>

</project>
16 changes: 5 additions & 11 deletions services-api/src/main/java/io/scalecube/services/ServiceCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@
import java.util.Optional;
import java.util.function.Function;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.Exceptions;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

public class ServiceCall {

private static final Logger LOGGER = LoggerFactory.getLogger(ServiceCall.class);

private ClientTransport transport;
private ServiceRegistry serviceRegistry;
private Router router;
Expand Down Expand Up @@ -355,14 +351,12 @@ private ServiceMessage toServiceMessage(MethodInfo methodInfo, Object request) {
.build();
}

private ServiceUnavailableException noReachableMemberException(ServiceMessage request) {
LOGGER.error(
"Failed to invoke service, "
+ "No reachable member with such service definition [{}], args [{}]",
request.qualifier(),
request);
private static ServiceUnavailableException noReachableMemberException(ServiceMessage request) {
return new ServiceUnavailableException(
"No reachable member with such service: " + request.qualifier());
"No reachable member with such service: "
+ request.qualifier()
+ ", failed request: "
+ request);
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.scalecube.services.auth;

import java.util.Map;
import reactor.core.publisher.Mono;

public interface CredentialsSupplier {

Mono<Map<String, String>> credentials(Map<String, String> tags);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package io.scalecube.services.auth;

public interface CredentialsSuppliers {

CredentialsSupplier forServiceRole(String serviceRole);
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,12 @@
import java.util.Optional;
import java.util.StringJoiner;
import org.reactivestreams.Publisher;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.util.context.Context;

public final class ServiceMethodInvoker {

private static final Logger LOGGER = LoggerFactory.getLogger(ServiceMethodInvoker.class);

private final Method method;
private final Object service;
private final MethodInfo methodInfo;
Expand Down Expand Up @@ -164,8 +160,8 @@ private Mono<Object> authenticate(ServiceMessage message, Context context) {
if (context.hasKey(AUTH_CONTEXT_KEY)) {
return Mono.just(context.get(AUTH_CONTEXT_KEY));
} else {
LOGGER.error("Authentication failed (auth context not found and authenticator not set)");
throw new UnauthorizedException("Authentication failed");
throw new UnauthorizedException(
"Authentication failed (auth context not found and authenticator not set)");
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package io.scalecube.services.routing;

import java.util.concurrent.ConcurrentHashMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import reactor.core.Exceptions;

public final class Routers {
private static final Logger LOGGER = LoggerFactory.getLogger(Routers.class);

private static final ConcurrentHashMap<Class<? extends Router>, Router> routers =
new ConcurrentHashMap<>();
Expand All @@ -28,7 +25,6 @@ private static Router create(Class<? extends Router> routerType) {
try {
return routerType.newInstance();
} catch (Exception ex) {
LOGGER.error("Create router type: {} failed: {}", routerType, ex);
throw Exceptions.propagate(ex);
}
}
Expand Down
9 changes: 7 additions & 2 deletions services/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
Expand All @@ -22,7 +24,10 @@
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.jctools</groupId>
<artifactId>jctools-core</artifactId>
Expand Down

0 comments on commit 775ee5c

Please sign in to comment.