github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/actor/middleware/opentracing/envelope.go (about)

     1  package opentracing
     2  
     3  import (
     4  	"github.com/asynkron/protoactor-go/actor"
     5  	"github.com/opentracing/opentracing-go"
     6  )
     7  
     8  type messageHeaderReader struct {
     9  	ReadOnlyMessageHeader actor.ReadonlyMessageHeader
    10  }
    11  
    12  func (reader *messageHeaderReader) ForeachKey(handler func(key, val string) error) error {
    13  	if reader.ReadOnlyMessageHeader == nil {
    14  		return nil
    15  	}
    16  
    17  	for _, key := range reader.ReadOnlyMessageHeader.Keys() {
    18  		err := handler(key, reader.ReadOnlyMessageHeader.Get(key))
    19  		if err != nil {
    20  			return err
    21  		}
    22  	}
    23  
    24  	return nil
    25  }
    26  
    27  var _ opentracing.TextMapReader = &messageHeaderReader{}
    28  
    29  type messageEnvelopeWriter struct {
    30  	MessageEnvelope *actor.MessageEnvelope
    31  }
    32  
    33  func (writer *messageEnvelopeWriter) Set(key, val string) {
    34  	writer.MessageEnvelope.SetHeader(key, val)
    35  }
    36  
    37  var _ opentracing.TextMapWriter = &messageEnvelopeWriter{}