events: InvoiceCreated InvoiceSettled

pull/1/head
Edouard Paris 5 years ago
parent 7e99c5c717
commit 51a363e04a

@ -1,3 +1,15 @@
package events
type Event struct{}
const (
InvoiceCreated = "invoice.created"
InvoiceSettled = "invoice.settled"
)
type Event struct {
Type string
ID string
}
func New(kind string) *Event {
return &Event{Type: kind}
}

@ -42,6 +42,11 @@ func (p *pubSub) invoices(ctx context.Context, sub chan *events.Event) {
default:
invoice := <-invoices
p.logger.Debug("receive invoice", logging.Object("invoice", invoice))
if invoice.Settled {
sub <- events.New(events.InvoiceSettled)
} else {
sub <- events.New(events.InvoiceCreated)
}
}
}
}()

Loading…
Cancel
Save