Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #835

Merged
merged 5 commits into from
May 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ ScaleCube Services Features:
* pluggable api-gateway providers (http / websocket / rsocket)
* pluggable service transports (tcp / aeron / rsocket)
* pluggable encoders (json, SBE, Google protocol buffers)
* pluggable service security authentication and authorization providers.
* pluggable service security authentication and authorization providers.

User Guide:

Expand Down Expand Up @@ -103,7 +103,7 @@ seed.call().api(GreetingsService.class)
});

// await all instances to shutdown.
Mono.whenDelayError(seed.shutdown(), serviceNode.shutdown()).block();
Mono.whenDelayError(seed.shutdown(), serviceNode.shutdown()).block();
```

Basic Service Example:
Expand Down Expand Up @@ -141,7 +141,7 @@ Basic API-Gateway example:
```java

Microservices.builder()
.discovery(options -> options.seeds(seed.discovery().address()))
.discovery(options -> options.seeds(seed.discoveryAddress()))
.services(...) // OPTIONAL: services (if any) as part of this node.

// configure list of gateways plugins exposing the apis
Expand Down Expand Up @@ -227,7 +227,7 @@ To add a dependency on ScaleCube Services using Maven, use the following:

----

## Sponsored by:
## Sponsored by:
* [OM2](https://www.om2.com/)
* [exberry.io](https://exberry.io/)

Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@

<distributionManagement.url>https://maven.pkg.github.com/scalecube/scalecube-services
</distributionManagement.url>
<checkstyle.skip>true</checkstyle.skip>
</properties>

<modules>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ private ServiceMessage toServiceMessage(MethodInfo methodInfo, Object request) {

private ServiceUnavailableException noReachableMemberException(ServiceMessage request) {
LOGGER.error(
"Failed to invoke service, "
"Failed to invoke service, "
+ "No reachable member with such service definition [{}], args [{}]",
request.qualifier(),
request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@ public interface Authenticator<R> extends Function<Map<String, String>, Mono<R>>
Object NULL_AUTH_CONTEXT = new Object();

String AUTH_CONTEXT_KEY = "auth.context";

static <T> Mono<T> deferSecured(Class<T> authDataType) {
return Mono.deferContextual(context -> Mono.just(context.get(AUTH_CONTEXT_KEY)))
.cast(authDataType);
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
package io.scalecube.services.discovery.api;

import io.scalecube.net.Address;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

public interface ServiceDiscovery {

/**
* Function to subscribe and listen on stream of {@code ServiceDiscoveryEvent}\s.
* Return listening address.
*
* @return stream of {@code ServiceDiscoveryEvent}\s
* @return listening address, or null if {@link #start()} was not called.
*/
Flux<ServiceDiscoveryEvent> listen();
Address address();

/**
* Starting this {@code ServiceDiscovery} instance.
* Function to subscribe and listen on stream of {@code ServiceDiscoveryEvent}\s.
*
* @return started {@code ServiceDiscovery} instance
* @return stream of {@code ServiceDiscoveryEvent}\s
*/
Mono<Void> start();
Flux<ServiceDiscoveryEvent> listen();

/**
* Shutting down this {@code ServiceDiscovery} instance.
*
* @return async signal of the result
* Starts this {@link ServiceDiscovery} instance. After started - subscribers begin to receive
* {@code ServiceDiscoveryEvent}\s on {@link #listen()}.
*/
Mono<Void> shutdown();
void start();

/** Stops this {@link ServiceDiscovery} instance and release occupied resources. */
void shutdown();
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,46 @@

import io.scalecube.services.ServiceEndpoint;
import java.util.StringJoiner;
import java.util.UUID;
import java.util.function.Consumer;

public final class ServiceDiscoveryOptions {
public final class ServiceDiscoveryOptions implements Cloneable {

private String id = UUID.randomUUID().toString();
private ServiceEndpoint serviceEndpoint;
private ServiceDiscoveryFactory discoveryFactory;

public ServiceDiscoveryOptions() {}

/**
* ServiceDiscoveryOptions copy constructor.
*
* @param other ServiceDiscoveryOptions to copy
*/
public ServiceDiscoveryOptions(ServiceDiscoveryOptions other) {
this.id = other.id;
this.serviceEndpoint = other.serviceEndpoint;
this.discoveryFactory = other.discoveryFactory;
}

private ServiceDiscoveryOptions set(Consumer<ServiceDiscoveryOptions> c) {
ServiceDiscoveryOptions s = new ServiceDiscoveryOptions(this);
c.accept(s);
return s;
}

public ServiceDiscoveryOptions id(String id) {
return set(o -> o.id = id);
}

public String id() {
return id;
public ServiceEndpoint serviceEndpoint() {
return serviceEndpoint;
}

public ServiceDiscoveryOptions serviceEndpoint(ServiceEndpoint serviceEndpoint) {
return set(o -> o.serviceEndpoint = serviceEndpoint);
final ServiceDiscoveryOptions c = clone();
c.serviceEndpoint = serviceEndpoint;
return c;
}

public ServiceEndpoint serviceEndpoint() {
return serviceEndpoint;
public ServiceDiscoveryFactory discoveryFactory() {
return discoveryFactory;
}

public ServiceDiscoveryOptions discoveryFactory(ServiceDiscoveryFactory discoveryFactory) {
return set(o -> o.discoveryFactory = discoveryFactory);
final ServiceDiscoveryOptions c = clone();
c.discoveryFactory = discoveryFactory;
return c;
}

public ServiceDiscoveryFactory discoveryFactory() {
return discoveryFactory;
@Override
public ServiceDiscoveryOptions clone() {
try {
return (ServiceDiscoveryOptions) super.clone();
} catch (CloneNotSupportedException e) {
throw new RuntimeException(e);
}
}

@Override
public String toString() {
return new StringJoiner(", ", ServiceDiscoveryOptions.class.getSimpleName() + "[", "]")
.add("id='" + id + "'")
.add("serviceEndpoint=" + serviceEndpoint)
.add("discoveryFactory=" + discoveryFactory)
.toString();
Expand Down
Loading