Elffuss BraidHub

kikocis/EDC public

main · 7.0 KiBSourceRawPermalink

Processing Callbacks

Decision

Implement the ability for clients to specify callback endpoints to be invoked at specific points during request processing:

Rationale

Currently, the EDC provides support for listeners (e.g. TransferProcessListener) and event subscribers (EventSubscriber). However, there is no way to provide callback endpoint information that can be used by listener and subscriber implementations when a request is made via the Management API. Processing callbacks will address this gap and provide support for invoking HTTPS endpoints.

Note, this functionality can also be used to align EDR handling with the migration to the IDS Dataspace Protocol specifications.

Configuration Scheme

Support for two types of callbacks will be implemented: static endpoints and dynamic endpoints. Static endpoints are configured in the EDC and referenced by identifier; dynamic endpoints are specified at the time a request is made.

Static Endpoints

The static endpoint registration will be done using a configuration extension. This allows for the development of more elaborate endpoint registration mechanisms in the future.

A static endpoint will be registered using EDC configuration:

edc.callback.endpoint1.uri=
edc.callback.endpoint1.events=
edc.callback.endpoint1.transactional=
edc.callback.endpoint1.auth-key=
edc.callback.endpoint1.auth-code-id=

The previous configuration will create a static endpoint registration for the id endpoint1 with the following properties:

Static callback endpoints are referenced by their id when a client makes a request. They may be reused by multiple requests.

Dynamic Endpoints

Dynamic endpoints are registered as part of a client request and are therefore scoped to the latter. Dynamic endpoints have three properties:

Dynamic endpoints do not have explicit API keys. Security can be provided at the network layer or through a URI with an randomly-generated single-use path part.

Event Naming

Event names will be constructed using a hierarchical period notation. For example, contract.negotiation.initiated. Abstract events can also be referenced. For example, contract.negotiation can be used to denote all contract negotiation subtypes.

New Services

The CallbackRegistry

A CallbackRegistry to manage static endpoints will be added to the control-plane-spi module:

package org.eclipse.edc.connector.spi.callback

public interface CallbackRegistry {

  void register(CallbackAddress address);
  
  List<CallbackAddress> resolve(String state);

}

This registry will be implemented in control-plane-aggregate-services as a simple, in-memory service. Dynamic endpoint will be persisted with the transfer process.

Impact on Existing Services

Management API

ContractNegotiationDto and TransferRequestDto will be enhanced to include a collection of CallbackAddress types that model dynamic endpoint configurations:

public class CallbackAddress {

    private String uri;
    
    private Set<String> events;

    private boolean transactional 

    ....
}

Provided dynamic callback addresses will be persisted alongside the request.

State Machines

During a state transition, a ContractNegotiationEventListener or TransferProcessEventListener will resolve CallbackAddress entries matching the state to be transitioned to by querying the CallbackRegistry and current TransferProcess. If a resolved callback is marked as transactional, an invocation error will mark the current transaction as rollback-only; otherwise, invocation errors will be logged and the transaction will proceed. Invocations will use the standard EDC retry mechanism.

Note that the event framework and EventRouter will be refactored to include contract negotiation and transfer process data as part of a pre-requisite Decision Record.

Note that transactional callback endpoints must be idempotent. De-duplication can be performed by comparing the associated process id and state with previous invocations.

Dispatching

Dispatching to callback endpoints will be performed by registered RemoteMessageDispatchers corresponding to the protocol part of the callback URI. These dispatchers will send events representing the ContractNegotiation or TransferProcess data received by the event listener.

DataFlowController

The DataFlowController interface will need to be changed to return an explicit result type. See below for details.

EndpointDataReferenceReceiver and Processing Callbacks

The existing mechanism for propagating and handling EndpointDataReferences will be adapted to processing callbacks. EDR configuration keys, e.g. edc.receiver.http.dynamic. and edc.receiver.http. will be aliases for the registration of CallbackAddress configurations.

Note we need to discuss whether to keep support of fallback edc.receiver.http.dynamic. endpoints. Also, we need to discuss continuing to support EndpointDataReferenceReceiver implementations. The implementations in EDC can be converted to RemoteMessageDispatchers but we need to discuss how to handle end-user supplied EndpointDataReferenceReceiver implementations.

The most significant change will involve propagating the EDR from the provider to the consumer. The new IDS protocol TransferStartMessage contains a dataAddress field that can be used to propagate the EDR instead of requiring the DataFlowController to send the EDR out-of-band to the client. The DataFlowController will need to return the EDR from the initiateFlow method using a DataFlowResponse:

 StatusResult<DataFlowResponse> initiateFlow(DataRequest dataRequest, DataAddress contentAddress, Policy policy);

If a reference is returned, it will be stored in the Vault and then sent with the TransferStartMessage by a dispatching listener. The client will receive the EDR and propagate it as part of its transfer process state transition.