Skip to main content

MonitorTransactionState

Server-Side Streaming Method

This method uses server-side streaming, meaning it returns multiple responses over time rather than a single response. The server sends a stream of responses to the client, and the client processes each response as it arrives.

Stream Lifecycle:

  • Initiation: Call the method to create a stream
  • Data Reception: Receive multiple responses over the stream
  • Completion: Stream ends normally (EOF/end event) or with an error
  • Resource Management: Streams should be fully consumed or explicitly closed

See the code examples below for language-specific streaming consumption patterns.

Method Details​

Description: Monitor Transaction state changes by the unique identifier of the transaction. Server-side streaming method that sends state updates as the transaction progresses.

Required Roles: Check proto file for roles

Parameters:

  • Name (string) (required): Name of the Transaction whose state is to be retrieved. Format: transactions/{ULIDv2}

Returns: Stream of MonitorTransactionStateResponse (server-streaming)

Method Type: METHOD_TYPE_WRITE

Code Examples​

package main

import (
"context"
"io"
"log"

transactionv1 "github.com/meshtrade/api/go/ledger/transaction/v1"
)

func main() {
ctx := context.Background()

// Default configuration is used and credentials come from MESH_API_CREDENTIALS
// environment variable or default discovery methods. Zero config required
// unless you want custom configuration.
service, err := transactionv1.NewTransactionService()
if err != nil {
log.Fatalf("Failed to create service: %v", err)
}
defer service.Close()

// Create request with service-specific parameters
request := &transactionv1.MonitorTransactionStateRequest{
// FIXME: Populate service-specific request fields
}

// Call the MonitorTransactionState streaming method
stream, err := service.MonitorTransactionState(ctx, request)
if err != nil {
log.Fatalf("Failed to initiate stream: %v", err)
}

// Consume stream responses
for {
response, err := stream.Recv()
if err == io.EOF {
break // Stream completed normally
}
if err != nil {
log.Fatalf("Stream error: %v", err)
}

// Process each response as it arrives
log.Printf("Received: %+v", response)
}

log.Println("Stream completed successfully")
}

Advanced Configuration​

For advanced client configuration options (custom endpoints, TLS settings, timeouts), see the SDK Configuration Guide.

Other Methods​