Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Datahub project Datahub MetadataWriteCallback Interface

From Leeroopedia
Revision as of 14:43, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Datahub_project_Datahub_MetadataWriteCallback_Interface.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Java_SDK, Metadata_Emission
Last Updated 2026-02-10 00:00 GMT

Overview

A Java interface that defines the asynchronous callback contract for metadata write operations in the DataHub client SDK.

Description

The Callback interface provides two methods that consumers implement to handle the outcome of asynchronous metadata emission requests. When a metadata change is sent through any emitter (REST, Kafka, S3), the callback is invoked upon completion or failure.

The onCompletion method receives a MetadataWriteResponse that may indicate either success or failure; callers must inspect the response object to determine the actual outcome. The onFailure method is invoked only when the request throws an exception before it can complete, representing a transport-level or serialization-level error rather than a server-side rejection.

This interface is used across all emitter implementations (KafkaEmitter, RestEmitter, S3Emitter) to provide a uniform asynchronous notification mechanism.

Usage

Implement this interface when you need to be notified asynchronously about the result of metadata emission. Pass the implementation as a parameter to the emit() methods on any Emitter implementation.

Code Reference

Source Location

metadata-integration/java/datahub-client/src/main/java/datahub/client/Callback.java

Signature

public interface Callback {
    void onCompletion(@Nullable MetadataWriteResponse response);
    void onFailure(Throwable exception);
}

Import

import datahub.client.Callback;

I/O Contract

Inputs

Method Parameter Type Description
onCompletion response @Nullable MetadataWriteResponse The response from the metadata write operation; may be null
onFailure exception Throwable The exception thrown before the request could complete

Outputs

Both methods return void. Side effects are determined by the implementing class (e.g., logging, retrying, updating state).

Usage Examples

Callback callback = new Callback() {
    @Override
    public void onCompletion(@Nullable MetadataWriteResponse response) {
        if (response != null && response.isSuccess()) {
            System.out.println("Metadata emitted successfully");
        } else {
            System.err.println("Metadata emission failed: " + response);
        }
    }

    @Override
    public void onFailure(Throwable exception) {
        System.err.println("Transport error: " + exception.getMessage());
    }
};

emitter.emit(mcpw, callback);

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment