Skip to content

Extract interface Availability #191

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

Merged
merged 5 commits into from
Nov 11, 2016
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2016 Netflix, Inc.
* <p>
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.reactivesocket;

public interface Availability {

/**
* @return a positive numbers representing the availability of the entity.
* Higher is better, 0.0 means not available
*/
double availability();

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
/**
* Represents a connection with input/output that the protocol uses.
*/
public interface DuplexConnection {
public interface DuplexConnection extends Availability {

/**
* Sends the source of {@link Frame}s on this connection and returns the {@code Publisher} representing the result
Expand Down Expand Up @@ -77,12 +77,6 @@ default Publisher<Void> sendOne(Frame frame) {
*/
Publisher<Frame> receive();

/**
* @return the availability of the underlying connection, a number in [0.0, 1.0]
* (higher is better).
*/
double availability();

/**
* Close this {@code DuplexConnection} upon subscribing to the returned {@code Publisher}
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@
package io.reactivesocket;

import org.reactivestreams.Publisher;
import io.reactivesocket.reactivestreams.extensions.Px;

/**
* A contract providing different interaction models for <a href="https://github.com/ReactiveSocket/reactivesocket/blob/master/Protocol.md">ReactiveSocket protocol</a>.
*/
public interface ReactiveSocket {
public interface ReactiveSocket extends Availability {

/**
* Fire and Forget interaction model of {@code ReactiveSocket}.
Expand Down Expand Up @@ -71,11 +70,7 @@ public interface ReactiveSocket {
*/
Publisher<Void> metadataPush(Payload payload);

/**
* Client check for availability to send request based on lease
*
* @return 0.0 to 1.0 indicating availability of sending requests
*/
@Override
default double availability() {
return 0.0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
package io.reactivesocket.client;

import io.reactivesocket.AbstractReactiveSocket;
import io.reactivesocket.Availability;
import io.reactivesocket.ReactiveSocket;
import io.reactivesocket.lease.DisabledLeaseAcceptingSocket;
import io.reactivesocket.lease.LeaseEnforcingSocket;
import io.reactivesocket.transport.TransportClient;
import org.reactivestreams.Publisher;

import java.util.function.Function;

public interface ReactiveSocketClient {
public interface ReactiveSocketClient extends Availability {

/**
* Creates a new {@code ReactiveSocket} every time the returned {@code Publisher} is subscribed.
Expand All @@ -34,12 +33,6 @@ public interface ReactiveSocketClient {
*/
Publisher<? extends ReactiveSocket> connect();

/**
* @return a positive numbers representing the availability of the factory.
* Higher is better, 0.0 means not available
*/
double availability();

/**
* Creates a new instances of {@code ReactiveSocketClient} using the passed {@code transportClient}. This client
* will not accept any requests from the server, so the client is half duplex. To create full duplex clients use
Expand Down