Package datahub.client.rest
Class RestEmitter
java.lang.Object
datahub.client.rest.RestEmitter
- All Implemented Interfaces:
Emitter
,Closeable
,AutoCloseable
-
Constructor Summary
ConstructorsConstructorDescriptionRestEmitter
(RestEmitterConfig config) The default constructor, prefer using the `create` factory method. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
static RestEmitter
create
(Consumer<RestEmitterConfig.RestEmitterConfigBuilder> builderSupplier) Constructing a REST Emitter follows a lambda-based fluent builder pattern using the `create` method.static RestEmitter
Creates a RestEmitter with default settings.Asynchronously emit aMetadataChangeProposal
event.Asynchronously emit aMetadataChangeProposalWrapper
event.Asynchronously emit aUpsertAspectRequest
.boolean
Test that the emitter can establish a valid connection to the DataHub platform
-
Constructor Details
-
RestEmitter
The default constructor, prefer using the `create` factory method.- Parameters:
config
-
-
-
Method Details
-
create
public static RestEmitter create(Consumer<RestEmitterConfig.RestEmitterConfigBuilder> builderSupplier) Constructing a REST Emitter follows a lambda-based fluent builder pattern using the `create` method. e.g. RestEmitter emitter = RestEmitter.create(b :: b .server("http://localhost:8080") // coordinates of gms server .extraHeaders(Collections.singletonMap("Custom-Header", "custom-val") ); You can also customize the underlying http client by calling the `customizeHttpAsyncClient` method on the builder. e.g. RestEmitter emitter = RestEmitter.create(b :: b .server("http://localhost:8080") .extraHeaders(Collections.singletonMap("Custom-Header", "custom-val") .customizeHttpAsyncClient(c :: c.setConnectionTimeToLive(30, TimeUnit.SECONDS)) );- Parameters:
builderSupplier
-- Returns:
- a constructed RestEmitter. Call #testConnection to make sure this emitter has a valid connection to the server
-
createWithDefaults
Creates a RestEmitter with default settings.- Returns:
- a constructed RestEmitter. Call #test_connection to validate that this emitter can communicate with the server.
-
emit
public Future<MetadataWriteResponse> emit(datahub.event.MetadataChangeProposalWrapper mcpw, Callback callback) throws IOException Description copied from interface:Emitter
Asynchronously emit aMetadataChangeProposalWrapper
event.- Specified by:
emit
in interfaceEmitter
callback
- if not null, is called from the IO thread. Should be a quick operation.- Returns:
- a
Future
for callers to inspect the result of the operation or block until one is available - Throws:
IOException
-
emit
public Future<MetadataWriteResponse> emit(com.linkedin.mxe.MetadataChangeProposal mcp, Callback callback) throws IOException Description copied from interface:Emitter
Asynchronously emit aMetadataChangeProposal
event. Prefer using the sibling method that accepts aMetadataChangeProposalWrapper
event as those are friendlier to construct.- Specified by:
emit
in interfaceEmitter
callback
- if not null, is called from the IO thread. Should be a quick operation.- Returns:
- a
Future
for callers to inspect the result of the operation or block until one is available - Throws:
IOException
-
testConnection
Description copied from interface:Emitter
Test that the emitter can establish a valid connection to the DataHub platform- Specified by:
testConnection
in interfaceEmitter
- Returns:
- true if a valid connection can be established, false or throws one of the exceptions otherwise
- Throws:
IOException
ExecutionException
InterruptedException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
emit
public Future<MetadataWriteResponse> emit(List<datahub.event.UpsertAspectRequest> request, Callback callback) throws IOException Description copied from interface:Emitter
Asynchronously emit aUpsertAspectRequest
.- Specified by:
emit
in interfaceEmitter
- Parameters:
request
- request with with metadata aspect to upsert into DataHub- Returns:
- a
Future
for callers to inspect the result of the operation or block until one is available - Throws:
IOException
-