Skip to content

Commit

Permalink
Move Fetchable and Bidirectional to ObjectService
Browse files Browse the repository at this point in the history
  • Loading branch information
devinrsmith committed Sep 19, 2023
1 parent 2be72bb commit af216c0
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 72 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import io.deephaven.client.impl.HasTypedTicket;
import io.deephaven.client.impl.ObjectService.MessageStream;
import io.deephaven.client.impl.ServerObject;
import io.deephaven.client.impl.ServerObject.Bidirectional;
import io.deephaven.client.impl.ServerObject.Fetchable;
import io.deephaven.client.impl.ObjectService.Bidirectional;
import io.deephaven.client.impl.ObjectService.Fetchable;
import io.deephaven.client.impl.TableHandle;
import io.deephaven.client.impl.TableHandle.TableHandleException;
import io.deephaven.client.impl.TableObject;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import io.deephaven.client.impl.DataAndExports;
import io.deephaven.client.impl.ServerObject;
import io.deephaven.client.impl.ServerObject.Fetchable;
import io.deephaven.client.impl.ObjectService.Fetchable;
import io.deephaven.client.impl.Session;
import picocli.CommandLine;
import picocli.CommandLine.ArgGroup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
*/
package io.deephaven.client.impl;

import io.deephaven.client.impl.ServerObject.Bidirectional;
import io.deephaven.client.impl.ServerObject.Fetchable;
import io.deephaven.client.impl.ObjectService.Bidirectional;
import io.deephaven.client.impl.ObjectService.Fetchable;

import java.util.Collections;
import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import com.google.protobuf.ByteString;
import io.deephaven.client.impl.ObjectService.MessageStream;
import io.deephaven.client.impl.ServerObject.Bidirectional;
import io.deephaven.client.impl.ServerObject.Fetchable;
import io.deephaven.client.impl.ObjectService.Bidirectional;
import io.deephaven.client.impl.ObjectService.Fetchable;
import io.deephaven.proto.backplane.grpc.Data;
import io.deephaven.proto.backplane.grpc.FetchObjectResponse;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package io.deephaven.client.impl;

import com.google.protobuf.ByteString;
import io.deephaven.client.impl.ObjectService.Bidirectional;
import io.deephaven.client.impl.ObjectService.MessageStream;
import io.deephaven.proto.backplane.grpc.Data;

Expand All @@ -13,7 +14,7 @@

/**
* Data and typed tickets to be sent from the client to the server as part of a
* {@link io.deephaven.client.impl.ServerObject.Bidirectional#messageStream(MessageStream) bidirection message stream}.
* {@link Bidirectional#messageStream(MessageStream) bidirection message stream}.
*/
public final class DataAndTypedTickets {
private final ByteBuffer data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,64 @@
*/
package io.deephaven.client.impl;

import io.deephaven.client.impl.ServerObject.Bidirectional;
import io.deephaven.client.impl.ServerObject.Fetchable;

import java.util.concurrent.CompletableFuture;

public interface ObjectService {

/**
* A server object that supports fetching.
*/
interface Fetchable extends ServerObject {
/**
* The type.
*
* @return the type
*/
String type();

/**
* Fetches {@code this}. The resulting object is managed separately than {@code this}.
*
* @return the future
* @see Session#fetch(HasTypedTicket) for the lower-level interface
*/
CompletableFuture<DataAndExports> fetch();
}

/**
* A server object that supports a bidirectional message stream.
*/
interface Bidirectional extends ServerObject {
/**
* The type.
*
* @return the type
*/
String type();

/**
* Opens a bidirectional message stream for {@code this}. The returned {@link DataAndExports} messages are
* managed separately than {@code this}.
*
* <p>
* This provides a generic stream feature for Deephaven instances to use to add arbitrary functionality. This
* API lets a client open a stream to a particular object on the server, to be mediated by a server side plugin.
* In theory this could effectively be used to "tunnel" a custom gRPC call, but in practice there are a few
* deliberate shortcomings that still make this possible, but not trivial.
*
* <p>
* Presently it is required that the server respond immediately, at least to acknowledge that the object was
* correctly contacted (as opposed to waiting for a pending ticket, or dealing with network lag, etc). This is a
* small (and possibly not required, but convenient) departure from a offering a gRPC stream (a server-streaming
* or bidi-streaming call need not send a message right away).
*
* @param stream the stream where the client will receive messages
* @return the stream where the client will send messages
* @see Session#messageStream(HasTypedTicket, MessageStream) for the lower-level interface
*/
MessageStream<DataAndTypedTickets> messageStream(MessageStream<DataAndExports> stream);
}

/**
* The sending and receiving interface for {@link #messageStream(HasTypedTicket, MessageStream)}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*/
package io.deephaven.client.impl;

import io.deephaven.client.impl.ObjectService.MessageStream;

import java.io.Closeable;
import java.util.concurrent.CompletableFuture;

Expand All @@ -28,58 +26,4 @@ public interface ServerObject extends HasExportId, Closeable {
*/
@Override
void close();

/**
* A server object that supports fetching.
*/
interface Fetchable extends ServerObject {
/**
* The type.
*
* @return the type
*/
String type();

/**
* Fetches {@code this}. The resulting object is managed separately than {@code this}.
*
* @return the future
* @see Session#fetch(HasTypedTicket) for the lower-level interface
*/
CompletableFuture<DataAndExports> fetch();
}

/**
* A server object that supports a bidirectional message stream.
*/
interface Bidirectional extends ServerObject {
/**
* The type.
*
* @return the type
*/
String type();

/**
* Opens a bidirectional message stream for {@code this}. The returned {@link DataAndExports} messages are
* managed separately than {@code this}.
*
* <p>
* This provides a generic stream feature for Deephaven instances to use to add arbitrary functionality. This
* API lets a client open a stream to a particular object on the server, to be mediated by a server side plugin.
* In theory this could effectively be used to "tunnel" a custom gRPC call, but in practice there are a few
* deliberate shortcomings that still make this possible, but not trivial.
*
* <p>
* Presently it is required that the server respond immediately, at least to acknowledge that the object was
* correctly contacted (as opposed to waiting for a pending ticket, or dealing with network lag, etc). This is a
* small (and possibly not required, but convenient) departure from a offering a gRPC stream (a server-streaming
* or bidi-streaming call need not send a message right away).
*
* @param stream the stream where the client will receive messages
* @return the stream where the client will send messages
* @see Session#messageStream(HasTypedTicket, MessageStream) for the lower-level interface
*/
MessageStream<DataAndTypedTickets> messageStream(MessageStream<DataAndExports> stream);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
*/
package io.deephaven.client.impl;

import io.deephaven.client.impl.ServerObject.Bidirectional;
import io.deephaven.client.impl.ServerObject.Fetchable;
import io.deephaven.client.impl.script.Changes;
import io.deephaven.proto.DeephavenChannel;
import io.deephaven.proto.backplane.grpc.AddTableRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
*/
package io.deephaven.client.impl;

import io.deephaven.client.impl.ObjectService.Bidirectional;
import io.deephaven.client.impl.ObjectService.Fetchable;

/**
* A server object that is <b>not</b> {@link io.deephaven.client.impl.ServerObject.Fetchable} nor
* {@link io.deephaven.client.impl.ServerObject.Bidirectional}; the server does not have a registration for the
* underlying object.
* A server object that is <b>not</b> {@link Fetchable} nor {@link Bidirectional}; the server does not have a
* registration for the underlying object.
*/
public final class UnknownObject extends ServerObjectBase implements ServerObject {

Expand Down

0 comments on commit af216c0

Please sign in to comment.