github.com/wfusion/gofusion@v1.1.14/common/infra/watermill/message/metadata.go (about)

     1  package message
     2  
     3  // Metadata is sent with every message to provide extra context without unmarshaling the message payload.
     4  type Metadata map[string]string
     5  
     6  // Get returns the metadata value for the given key. If the key is not found, an empty string is returned.
     7  func (m Metadata) Get(key string) string {
     8  	if v, ok := m[key]; ok {
     9  		return v
    10  	}
    11  
    12  	return ""
    13  }
    14  
    15  // Set sets the metadata key to value.
    16  func (m Metadata) Set(key, value string) {
    17  	m[key] = value
    18  }