-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
jni: update java library interfaces (#326)
Updating java library layer to conform to the streaming interfaces changes. Also, tweaks to make the java layer more consistent with the ObjC layer in envoyproxy/envoy-mobile#327 Signed-off-by: Alan Chiu <achiu@lyft.com> For an explanation of how to fill out the fields, please see the relevant section in [PULL_REQUESTS.md](https://github.com/envoyproxy/envoy/blob/master/PULL_REQUESTS.md) Description: Updating java library interfaces Risk Level: low Testing: n/a Docs Changes: n/a Release Notes: n/a [Optional Fixes #Issue] [Optional Deprecated:] Signed-off-by: JP Simard <jp@jpsim.com>
- Loading branch information
Showing
10 changed files
with
217 additions
and
222 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 0 additions & 84 deletions
84
mobile/library/java/src/io/envoyproxy/envoymobile/engine/Engine.java
This file was deleted.
Oops, something went wrong.
115 changes: 14 additions & 101 deletions
115
mobile/library/java/src/io/envoyproxy/envoymobile/engine/EnvoyEngine.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,117 +1,30 @@ | ||
package io.envoyproxy.envoymobile.engine; | ||
|
||
import io.envoyproxy.envoymobile.engine.types.EnvoyData; | ||
import io.envoyproxy.envoymobile.engine.types.EnvoyHeaders; | ||
import io.envoyproxy.envoymobile.engine.types.EnvoyObserver; | ||
import io.envoyproxy.envoymobile.engine.types.EnvoyStatus; | ||
import io.envoyproxy.envoymobile.engine.types.EnvoyStream; | ||
|
||
public class EnvoyEngine implements Engine { | ||
public interface EnvoyEngine { | ||
/** | ||
* Open an underlying HTTP stream. | ||
* Creates a new stream with the provided observer. | ||
* | ||
* @param observer, the observer that will run the stream callbacks. | ||
* @return EnvoyStream, with a stream handle and a success status, or a failure status. | ||
* @param observer The observer for receiving callbacks from the stream. | ||
* @return A stream that may be used for sending data. | ||
*/ | ||
@Override | ||
public EnvoyStream startStream(EnvoyObserver observer) { | ||
// TODO: Implement | ||
throw new UnsupportedOperationException("TODO: Implement me"); | ||
} | ||
EnvoyStream startStream(EnvoyObserver observer); | ||
|
||
/** | ||
* Send headers over an open HTTP stream. This method can be invoked once and needs to be called | ||
* before send_data. | ||
* Run the Envoy engine with the provided config and log level. | ||
* | ||
* @param stream, the stream to send headers over. | ||
* @param headers, the headers to send. | ||
* @param endStream, supplies whether this is headers only. | ||
* @return EnvoyStatus, the resulting status of the operation. | ||
* @param config The configuration file with which to start Envoy. | ||
* @return A status indicating if the action was successful. | ||
*/ | ||
@Override | ||
public EnvoyStatus sendHeaders(EnvoyStream stream, EnvoyHeaders headers, boolean endStream) { | ||
// TODO: Implement | ||
throw new UnsupportedOperationException("TODO: Implement me"); | ||
} | ||
int runWithConfig(String config); | ||
|
||
/** | ||
* Send data over an open HTTP stream. This method can be invoked multiple times. | ||
* Run the Envoy engine with the provided config and log level. | ||
* | ||
* @param stream, the stream to send data over. | ||
* @param data, the data to send. | ||
* @param endStream, supplies whether this is the last data in the stream. | ||
* @return EnvoyStatus, the resulting status of the operation. | ||
* @param config The configuration file with which to start Envoy. | ||
* @param logLevel The log level to use when starting Envoy. | ||
* @return int A status indicating if the action was successful. | ||
*/ | ||
@Override | ||
public EnvoyStatus sendData(EnvoyStream stream, EnvoyData data, boolean endStream) { | ||
// TODO: Implement | ||
throw new UnsupportedOperationException("TODO: Implement me"); | ||
} | ||
|
||
/** | ||
* Send metadata over an HTTP stream. This method can be invoked multiple times. | ||
* | ||
* @param stream, the stream to send metadata over. | ||
* @param metadata, the metadata to send. | ||
* @param endStream, supplies whether this is the last data in the stream. | ||
* @return EnvoyStatus, the resulting status of the operation. | ||
*/ | ||
@Override | ||
public EnvoyStatus sendMetadata(EnvoyStream stream, EnvoyHeaders metadata, boolean endStream) { | ||
// TODO: Implement | ||
throw new UnsupportedOperationException("TODO: Implement me"); | ||
} | ||
|
||
/** | ||
* Send trailers over an open HTTP stream. This method can only be invoked once per stream. | ||
* Note that this method implicitly ends the stream. | ||
* | ||
* @param stream, the stream to send trailers over. | ||
* @param trailers, the trailers to send. | ||
* @return EnvoyStatus, the resulting status of the operation. | ||
*/ | ||
@Override | ||
public EnvoyStatus sendTrailers(EnvoyStream stream, EnvoyHeaders trailers) { | ||
// TODO: Implement | ||
throw new UnsupportedOperationException("TODO: Implement me"); | ||
} | ||
|
||
/** | ||
* Half-close an HTTP stream. The stream will be observable and may return further data | ||
* via the observer callbacks. However, nothing further may be sent. | ||
* | ||
* @param stream, the stream to close. | ||
* @return EnvoyStatus, the resulting status of the operation. | ||
*/ | ||
@Override | ||
public EnvoyStatus locallyCloseStream(EnvoyStream stream) { | ||
// TODO: Implement | ||
throw new UnsupportedOperationException("TODO: Implement me"); | ||
} | ||
|
||
/** | ||
* Detach all observers from a stream and send an EnvoyStatuserrupt upstream if supported by | ||
* transport. | ||
* | ||
* @param stream, the stream to evict. | ||
* @return EnvoyStatus, the resulting status of the operation. | ||
*/ | ||
@Override | ||
public EnvoyStatus resetStream(EnvoyStream stream) { | ||
// TODO: Implement | ||
throw new UnsupportedOperationException("TODO: Implement me"); | ||
} | ||
|
||
/** | ||
* External entry poEnvoyStatus for library. | ||
* | ||
* @param config, the configuration blob to run envoy with. | ||
* @param logLevel, the logging level to run envoy with. | ||
* @return EnvoyStatus, the resulting status of the operation. | ||
*/ | ||
@Override | ||
public EnvoyStatus runEngine(String config, String logLevel) { | ||
int status = JniLibrary.runEngine(config, logLevel); | ||
return status == 0 ? EnvoyStatus.ENVOY_SUCCESS : EnvoyStatus.ENVOY_FAILURE; | ||
} | ||
int runWithConfig(String config, String logLevel); | ||
} |
50 changes: 50 additions & 0 deletions
50
mobile/library/java/src/io/envoyproxy/envoymobile/engine/EnvoyEngineImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.envoyproxy.envoymobile.engine; | ||
|
||
import io.envoyproxy.envoymobile.engine.types.EnvoyObserver; | ||
|
||
public class EnvoyEngineImpl implements EnvoyEngine { | ||
|
||
private final long engineHandle; | ||
|
||
public EnvoyEngineImpl() { this.engineHandle = JniLibrary.initEngine(); } | ||
|
||
/** | ||
* Creates a new stream with the provided observer. | ||
* | ||
* @param observer The observer for receiving callbacks from the stream. | ||
* @return A stream that may be used for sending data. | ||
*/ | ||
@Override | ||
public EnvoyStream startStream(EnvoyObserver observer) { | ||
long streamHandle = JniLibrary.initStream(engineHandle); | ||
return new EnvoyStream(streamHandle, observer); | ||
} | ||
|
||
/** | ||
* Run the Envoy engine with the provided config and log level. | ||
* | ||
* @param config The configuration file with which to start Envoy. | ||
* @return A status indicating if the action was successful. | ||
*/ | ||
@Override | ||
public int runWithConfig(String config) { | ||
return runWithConfig(config, "info"); | ||
} | ||
|
||
/** | ||
* Run the Envoy engine with the provided config and log level. | ||
* | ||
* @param config The configuration file with which to start Envoy. | ||
* @param logLevel The log level to use when starting Envoy. | ||
* @return int A status indicating if the action was successful. | ||
*/ | ||
@Override | ||
public int runWithConfig(String config, String logLevel) { | ||
try { | ||
return JniLibrary.runEngine(config, logLevel); | ||
} catch (Throwable throwable) { | ||
// TODO: Need to have a way to log the exception somewhere | ||
return 1; | ||
} | ||
} | ||
} |
Oops, something went wrong.