github.com/annwntech/go-micro/v2@v2.9.5/client/rpc_message.go (about)

     1  package client
     2  
     3  type message struct {
     4  	topic       string
     5  	contentType string
     6  	payload     interface{}
     7  }
     8  
     9  func newMessage(topic string, payload interface{}, contentType string, opts ...MessageOption) Message {
    10  	var options MessageOptions
    11  	for _, o := range opts {
    12  		o(&options)
    13  	}
    14  
    15  	if len(options.ContentType) > 0 {
    16  		contentType = options.ContentType
    17  	}
    18  
    19  	return &message{
    20  		payload:     payload,
    21  		topic:       topic,
    22  		contentType: contentType,
    23  	}
    24  }
    25  
    26  func (m *message) ContentType() string {
    27  	return m.contentType
    28  }
    29  
    30  func (m *message) Topic() string {
    31  	return m.topic
    32  }
    33  
    34  func (m *message) Payload() interface{} {
    35  	return m.payload
    36  }