Summary
Create ProvisioningEnvelope implementing grpcbroker.MessageEnvelope[ProvisioningMessage] to bridge proto messages with the generic MessageBroker. This handles request ID correlation, error extraction/wrapping, inner message extraction from the oneof, and progress message identification for Deploy, Preview, and Destroy operations.
Parent Epic
Part of #7465 — Provisioning Providers in the AZD Extension Framework
Context
The MessageBroker is a generic bidirectional stream handler that requires a MessageEnvelope implementation to understand the structure of the messages it's routing. Each extension capability has its own envelope:
ServiceTargetEnvelope in pkg/azdext/service_target_envelope.go
FrameworkServiceEnvelope in pkg/azdext/framework_service_envelope.go
The envelope must implement:
type MessageEnvelope[T any] interface {
GetRequestId(ctx context.Context, msg *T) string
SetRequestId(ctx context.Context, msg *T, id string)
GetError(msg *T) error
SetError(msg *T, err error)
GetInnerMessage(msg *T) any
IsProgressMessage(msg *T) bool
GetProgressMessage(msg *T) string
CreateProgressMessage(requestId string, message string) *T
}
Detailed Requirements
GetRequestId / SetRequestId
- Extract/set the
request_id field from ProvisioningMessage
- Used by the broker for request-response correlation
GetError / SetError
- Extract
ExtensionError from the message and convert to Go error using UnwrapError()
- Set
ExtensionError on the message using WrapError()
- Follows the pattern in
service_target_envelope.go
GetInnerMessage
- Extract the active oneof payload from
MessageType
- Return it as
any for reflection-based handler dispatch
IsProgressMessage / GetProgressMessage / CreateProgressMessage
IsProgressMessage returns true for ProvisioningDeployProgressMessage, ProvisioningPreviewProgressMessage, and ProvisioningDestroyProgressMessage
GetProgressMessage extracts the progress text string
CreateProgressMessage creates a new progress message with the given requestId and message text
Acceptance Criteria
Dependencies
Files
- Create:
pkg/azdext/provisioning_envelope.go
- Create:
pkg/azdext/provisioning_envelope_test.go
Summary
Create
ProvisioningEnvelopeimplementinggrpcbroker.MessageEnvelope[ProvisioningMessage]to bridge proto messages with the genericMessageBroker. This handles request ID correlation, error extraction/wrapping, inner message extraction from the oneof, and progress message identification for Deploy, Preview, and Destroy operations.Parent Epic
Part of #7465 — Provisioning Providers in the AZD Extension Framework
Context
The
MessageBrokeris a generic bidirectional stream handler that requires aMessageEnvelopeimplementation to understand the structure of the messages it's routing. Each extension capability has its own envelope:ServiceTargetEnvelopeinpkg/azdext/service_target_envelope.goFrameworkServiceEnvelopeinpkg/azdext/framework_service_envelope.goThe envelope must implement:
Detailed Requirements
GetRequestId/SetRequestIdrequest_idfield fromProvisioningMessageGetError/SetErrorExtensionErrorfrom the message and convert to GoerrorusingUnwrapError()ExtensionErroron the message usingWrapError()service_target_envelope.goGetInnerMessageMessageTypeanyfor reflection-based handler dispatchIsProgressMessage/GetProgressMessage/CreateProgressMessageIsProgressMessagereturns true forProvisioningDeployProgressMessage,ProvisioningPreviewProgressMessage, andProvisioningDestroyProgressMessageGetProgressMessageextracts the progress text stringCreateProgressMessagecreates a new progress message with the givenrequestIdand message textAcceptance Criteria
ProvisioningEnvelopestruct implementingMessageEnvelope[ProvisioningMessage]GetRequestId()extractsrequest_idfromProvisioningMessageSetRequestId()setsrequest_idonProvisioningMessageGetError()extractsExtensionErrorand converts viaUnwrapError()SetError()setsExtensionErrorviaWrapError()GetInnerMessage()extracts active oneof payloadIsProgressMessage()returns true for all 3 progress message typesGetProgressMessage()extracts progress textCreateProgressMessage()creates progress message with request_idDependencies
Files
pkg/azdext/provisioning_envelope.gopkg/azdext/provisioning_envelope_test.go