github.com/mundipagg/boleto-api@v0.0.0-20230620145841-3f9ec742599f/queue/queuePublisher.go (about)

     1  package queue
     2  
     3  import (
     4  	"github.com/mundipagg/boleto-api/config"
     5  )
     6  
     7  //Publisher Implementação da interface publisher
     8  type Publisher struct {
     9  	ExchangeName string
    10  	QueueName    string
    11  	RoutingKey   string
    12  	Message      string
    13  }
    14  
    15  func NewPublisher(message string) *Publisher {
    16  	p := new(Publisher)
    17  	p.ExchangeName = config.Get().OriginExchange
    18  	p.QueueName = config.Get().OriginQueue
    19  	p.RoutingKey = config.Get().OriginRoutingKey
    20  	p.Message = message
    21  
    22  	return p
    23  }
    24  
    25  //GetExchangeName Retorna o nome da fila
    26  func (p *Publisher) GetExchangeName() string {
    27  	return p.ExchangeName
    28  }
    29  
    30  //GetQueueName Retorna o nome da fila com sufixo identificador
    31  func (p *Publisher) GetQueueName() string {
    32  	return p.QueueName
    33  }
    34  
    35  //GetRoutingKey Retorna a RoutingKey para direcionamento da mensagem
    36  func (p *Publisher) GetRoutingKey() string {
    37  	return p.RoutingKey
    38  }
    39  
    40  //GetMessageToPublish Retorna a mensagem convertida para publicação na fila
    41  func (p *Publisher) GetMessageToPublish() []byte {
    42  	return []byte(p.Message)
    43  }