Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:Datahub project Datahub MetadataWriteCallback Interface

From Leeroopedia


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