liveBook · Manning

Metadata

As explained in API Design Patterns

Operation metadata is auxiliary information describing the progress or other properties of an executing or completed operation.

Metadata is auxiliary information about an operation’s progress or other properties. In long-running operations, it accompanies the eventual result without replacing it. section 10.6 section 10.3.1

Use metadata to:

  • Report progress or estimated time remaining before a result is available. section 10.3.1
  • Give an operation a typed metadata interface instead of exposing an unstructured value. section 10.3 section 10.3.1
  • Support discovery and filtering of operations by metadata, such as identifying paused work. section 10.3.8

Export progress

An asynchronous message export returns Operation<ExportMessagesResponse, ExportMessagesMetadata>. Its metadata stores progressPercent from 0% for not started to 100% for complete, while the result later contains the output configuration. section 2.4.3

Metadata is optional: an operation can use null when no metadata is worth storing. Do not confuse operation metadata with relationship metadata, which describes the relationship itself rather than execution progress. section 10.3.1 section 15.4.2

Listing 10.4 Definition of the Operation and OperationError interfaces
interface Operation<ResultT, MetadataT> {  #1
  id: string;
  done: boolean;                           #2
  result?: ResultT | OperationError;       #1    
  metadata?: MetadataT;                    #1    
}
 
interface OperationError {
  code: string;
  message: string;
  details?: any;
}

Inspect the generic Operation interface to see how typed metadata sits alongside completion status and the eventual result or error. section 10.3.1

How API Design Patterns covers it

How deep it goes
Defines typed operation metadata, gives progress examples, and stops short of specifying a universal metadata schema.
Examples
Uses message-export progress percentages, estimated time remaining, paused-operation filtering, and generic Operation interfaces.
What it assumes
Assumes long-running operations and generic result types, while teaching metadata typing and optionality.
What you can do after
Build it from scratch by parameterizing an Operation with a typed metadata interface and exposing metadata for progress or filtering.
How it connects
Connects metadata with long-running operations, asynchronous API calls, operation resources, result types, and filtering.

Also explained in

Compare how 21 books explain metadata →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of API Design Patterns. The section links point to the parts of the book it draws on.