Skip to content

Commit

Permalink
Redesign API for more use cases
Browse files Browse the repository at this point in the history
This eliminates the dichotomy between synchronous and asynchronous
clients; clients are always synchronous. The presence of virtual
threads means that it is now trivial to cheaply treat anything
synchronous as asynchronous without having to provide an API for it.

The test suite now contains implementation examples for TCP, UDP,
and HTTP clients.

Fix: #2
  • Loading branch information
io7m committed Apr 6, 2024
1 parent be683ed commit 95230d4
Show file tree
Hide file tree
Showing 110 changed files with 6,107 additions and 4,138 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,31 +19,31 @@
/**
* A factory of clients.
*
* @param <X> The type of exceptions that can be raised by clients
* @param <G> The type of client configuration values
* @param <C> The type of commands sent to the server by the client
* @param <R> The type of responses returned from the server
* @param <RS> The type of success responses returned from the server
* @param <RF> The type of failure responses returned from the server
* @param <E> The type of events received from the server
* @param <CR> The type of credentials
* @param <LA> The type of asynchronous clients
* @param <LS> The type of synchronous clients
* @param <C> The type of configurations
* @param <M> The type of messages
* @param <P> The type of connection parameters
* @param <T> The type of clients
* @param <X> the type of exceptions
*/

public interface HBClientFactoryType<
X extends Exception,
G extends HBConfigurationType,
C extends HBCommandType,
R extends HBResponseType,
RS extends R,
RF extends R,
E extends HBEventType,
CR extends HBCredentialsType,
LA extends HBClientAsynchronousType<X, C, R, RS, RF, E, CR>,
LS extends HBClientSynchronousType<X, C, R, RS, RF, E, CR>>
extends HBClientAsynchronousFactoryType<X, G, C, R, RS, RF, E, CR, LA>,
HBClientSynchronousFactoryType<X, G, C, R, RS, RF, E, CR, LS>
C extends HBConfigurationType,
M extends HBMessageType,
P extends HBConnectionParametersType,
T extends HBClientType<M, P, X>,
X extends Exception>
{
/**
* Create a new client.
*
* @param configuration The client configuration
*
* @return The new client
*
* @throws X On errors
*/

T create(
C configuration)
throws X;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,42 +20,25 @@

/**
* Status information for a client.
*
* @param <C> The type of commands sent by the client
* @param <R> The type of responses returned from the server
* @param <RF> The type of responses returned that indicate failed commands
* @param <CR> The type of credentials
* @param <E> The type of events
*/

public interface HBClientStatusType<
C extends HBCommandType,
R extends HBResponseType,
RF extends R,
E extends HBEventType,
CR extends HBCredentialsType>
public interface HBClientStatusType
{
/**
* @return {@code true} if the client is connected
*/

boolean isConnected();

/**
* @return A stream of events received from the server
*/

Flow.Publisher<E> events();

/**
* @return A stream of state updates for the client
*/

Flow.Publisher<HBStateType<C, R, RF, CR>> state();
Flow.Publisher<HBStateType> state();

/**
* @return The value of {@link #state()} right now
*/

HBStateType<C, R, RF, CR> stateNow();
HBStateType stateNow();
}

This file was deleted.

Loading

0 comments on commit 95230d4

Please sign in to comment.