Package biopb.image
Class OpsClient
java.lang.Object
biopb.image.OpsClient
- All Implemented Interfaces:
AutoCloseable
A client of an algorithm server: the
Ops protocol over gRPC.
The Java twin of Python's biopb.image.OpsClient. Use connect(String) to make one. A call has no deadline: the inactivity timeout
bounds the silence between events instead, and leaving a call (an error, a
sink that throws, a timeout) cancels it on the server.
-
Constructor Summary
ConstructorsConstructorDescriptionA client over a channel the caller built (to set message size limits, credentials or a proxy).A client of the server aturl, agrpc://orgrpcs://address. -
Method Summary
Modifier and TypeMethodDescriptioncall(String, Map, Consumer, List)with no progress sink and default axis labels.Run one op onvalues, by name: arrays go as pixels, anything else as JSON (seeArgCodec.encodeArg(java.lang.Object)).voidclose()Shut the channel down, waiting briefly for calls to finish.static OpsClientA client of the algorithm server attarget: agrpc://orgrpcs://URL, or the name of a registry entry the control manages.static OpsClientconnect(String)with an explicit token and inactivity timeout (either may be null).static OpsClientconnect(String target, String token, Duration inactivityTimeout, ControlClient control) connect(String, String, Duration)asking a given control, for tests and embedding.describe()The ops the server offers, within 10 seconds.The ops the server offers.voidHandsinkevery event of one call, progress-only ones included, until the server ends the stream.static io.grpc.ManagedChannelmakeChannel(String url) A channel to agrpc://orgrpcs://URL.url()The address this client dials.
-
Constructor Details
-
OpsClient
A client of the server aturl, agrpc://orgrpcs://address.- Parameters:
token- bearer token, or null for noneinactivityTimeout- longest silence between events before a call is given up on, or null for none- Throws:
IllegalArgumentException- the URL has no host or another scheme
-
OpsClient
A client over a channel the caller built (to set message size limits, credentials or a proxy). The client owns it:close()shuts it down.
-
-
Method Details
-
connect
A client of the algorithm server attarget: agrpc://orgrpcs://URL, or the name of a registry entry the control manages. A name is brought up through the control first (installing it if needed) and takes the server's own token; an explicittokenoverrides it.- Throws:
NoSuchElementException- a name the control does not knowIllegalStateException- the entry did not come up, or no control answered
-
connect
connect(String)with an explicit token and inactivity timeout (either may be null). -
connect
public static OpsClient connect(String target, String token, Duration inactivityTimeout, ControlClient control) connect(String, String, Duration)asking a given control, for tests and embedding. -
url
The address this client dials. -
close
public void close()Shut the channel down, waiting briefly for calls to finish.- Specified by:
closein interfaceAutoCloseable
-
describe
The ops the server offers, within 10 seconds. -
describe
The ops the server offers. -
events
Handsinkevery event of one call, progress-only ones included, until the server ends the stream. Returns when it does; asinkthat throws ends the call, which is cancelled on the server.- Throws:
OpTimeoutException- no event arrived within the inactivity timeoutIllegalArgumentException- the server refused the argumentsNoSuchElementException- the server has no such opIllegalStateException- any other failure
-
call
call(String, Map, Consumer, List)with no progress sink and default axis labels. -
call
public Object call(String op, Map<String, ?> values, Consumer<String> onProgress, List<String> dimLabels) Run one op onvalues, by name: arrays go as pixels, anything else as JSON (seeArgCodec.encodeArg(java.lang.Object)).Returns the op's result: its single output; an
Object[]of them in order for several;nullfor no output. A streaming op returns aList<Object>with one such value per event.- Parameters:
onProgress- receives each progress message, or nulldimLabels- labels every array argument's axes, or null for the defaults (ArgCodec.NDIM_LABELS)- Throws:
IllegalArgumentException- the server refused the argumentsNoSuchElementException- the server has no such opIllegalStateException- any other failure
-
makeChannel
A channel to agrpc://orgrpcs://URL.- Throws:
IllegalArgumentException- no host, or another scheme
-