Documentation ¶
Index ¶
- Constants
- func NewRabbitPublisher(file string, pool *database.Pool, mtx *sync.Mutex, dispatchers int) *migration.MessageService
- type Channels
- type Mailer
- func (m *Mailer) GetBody() string
- func (m *Mailer) GetMimeHeaders() string
- func (m *Mailer) GetSubject() string
- func (m *Mailer) GetTo() string
- func (m *Mailer) Send() error
- func (m *Mailer) SetBody(body string)
- func (m *Mailer) SetConfig(config map[string]string)
- func (m *Mailer) SetMimeHeaders(mimeHeaders string)
- func (m *Mailer) SetSubject(subject string)
- func (m *Mailer) SetTo(to string)
- type Rabbit
- func (r *Rabbit) Consume(queue string, callback func(amqp.Delivery)) error
- func (r *Rabbit) ConsumeResilient(queue string, callback func(amqp.Delivery)) error
- func (r *Rabbit) ConsumeWithContext(ctx context.Context, queue string, callback func(amqp.Delivery)) error
- func (r *Rabbit) DeclareExchange(exchange string) error
- func (r *Rabbit) DeclareQueue(queue, exchange, routingKey string) error
- func (r *Rabbit) Disconnect() error
- func (r *Rabbit) IsConnected() bool
- func (r *Rabbit) Publish(exchange, routingKey string, body []byte) error
- func (r *Rabbit) PublishFromCache(messageService *migration.MessageService, mtx *sync.Mutex) error
- type RabbitConfig
Constants ¶
const ( MESSAGING_TIMEOUT = 30 MAX_RETRIES = 3 )
Variables ¶
This section is empty.
Functions ¶
func NewRabbitPublisher ¶ added in v0.10.9
func NewRabbitPublisher(file string, pool *database.Pool, mtx *sync.Mutex, dispatchers int) *migration.MessageService
NewRabbitPublisher is a function that creates a new RabbitMQ publisher and publishes all messages from the database. It is used to publish messages that were not published due to a RabbitMQ connection failure. The messages are published unordered The table used to store the messages is: create table if not exists RabbitCache(RabbitCacheID string primary key, DE_Exchange string, DE_RoutingKey string, JS_Data text, SN_Durable integer, TS_Operacao string, ID_Status integer default 0) The table is created in memory and is not persisted. To send a message, you have to call the function Send of the message service that uses the same database connection. the function needs the following parameters: - exchange: the exchange name - routingKey: the routing key - data: the message data - durable: if the message is durable CAUTION: if you use more than one dispatcher, the messages can be sent more than once. You have to take care of this. The function returns a message service that can be used to send messages.
Types ¶
type Channels ¶
type Channels struct { // Channel for sending messages to the messaging adapter // Each message must have the following structure: // { // "EM_Destinatario": "email address", // "DE_Body": "message body", // "DE_Assunto": "message subject // } Email chan map[string]interface{} // Channel for sending messages to the messaging adapter // Each message must have the following structure: // { // "DE_Telefone": "phone number", // "DE_Mensagem": "message body", // } SMS chan map[string]string // Channel for sending messages to the messaging adapter // Each message must have the following structure: // { // "DE_Telefone": "phone number", // "DE_Mensagem": "message body", // } Whatsapp chan map[string]interface{} // Channel for sending messages to the messaging adapter // Each message must have the following structure: // { // "exchange": "exchange name", // "routingKey": "routing key", // "body": "message body", // "durable": "if the message is durable", // } Messaging chan map[string]interface{} // Channel for sending shutdown signal to the web server Shutdown chan bool // Channel for sending phonenumbers to be updated // Each message must have the following structure: // { // "UD_Proprietario": "person uuidv4", // "CO_DDD": "area code", // "CO_Telefone": "phone number", // "SN_Principal": "if the phone number is the main one", // } PhonenumberUpdate chan map[string]interface{} // Channel for sending emails to be updated // Each message must have the following structure: // { // "UD_Proprietario": "person uuidv4", // "EM_Email": "email address", // "SN_Principal": "if the email is the main one", // } EmailUpdate chan map[string]interface{} }
func NewChannels ¶
func NewChannels() *Channels
type Mailer ¶
type Mailer struct {
// contains filtered or unexported fields
}
func (*Mailer) GetMimeHeaders ¶
func (*Mailer) GetSubject ¶
func (*Mailer) SetMimeHeaders ¶
func (*Mailer) SetSubject ¶
type Rabbit ¶ added in v0.10.0
type Rabbit struct {
// contains filtered or unexported fields
}
func (*Rabbit) ConsumeResilient ¶ added in v0.10.28
func (*Rabbit) ConsumeWithContext ¶ added in v0.10.27
func (*Rabbit) DeclareExchange ¶ added in v0.10.0
func (*Rabbit) DeclareQueue ¶ added in v0.10.0
func (*Rabbit) Disconnect ¶ added in v0.10.0
func (*Rabbit) IsConnected ¶ added in v0.10.0
func (*Rabbit) PublishFromCache ¶ added in v0.10.0
type RabbitConfig ¶ added in v0.10.0
type RabbitConfig struct { DSN string `json:"dsn"` // contains filtered or unexported fields }
func (*RabbitConfig) LoadRabbitConfig ¶ added in v0.10.0
func (r *RabbitConfig) LoadRabbitConfig(file string) error