فهرست منبع

Add basic `Bus` methods.

Arto Bendiken 3 سال پیش
والد
کامیت
992af04560
1فایلهای تغییر یافته به همراه40 افزوده شده و 0 حذف شده
  1. 40 0
      bus.go

+ 40 - 0
bus.go

@@ -21,3 +21,43 @@ func Connect(url string) (*Bus, error) {
 	}
 	return &Bus{NATS: encodedConn}, nil
 }
+
+func (bus *Bus) SendEmail(request *SendEmail) error {
+	envelope := request // TODO
+	if err := bus.NATS.Publish("email.outbound", envelope); err != nil {
+		return fmt.Errorf("failed to enqueue outbound email: %w", err)
+	}
+	return nil
+}
+
+func (bus *Bus) RegisterID(request *RegisterID) error {
+	envelope := request // TODO
+	if err := bus.NATS.Publish("id.register", envelope); err != nil {
+		return fmt.Errorf("failed to enqueue ID registration: %w", err)
+	}
+	return nil
+}
+
+func (bus *Bus) VerifyEmail(request *VerifyEmail) error {
+	envelope := request // TODO
+	if err := bus.NATS.Publish("id.verify", envelope); err != nil {
+		return fmt.Errorf("failed to enqueue ID verification: %w", err)
+	}
+	return nil
+}
+
+func (bus *Bus) GrantAccess(request *GrantAccess) error {
+	envelope := request // TODO
+	if err := bus.NATS.Publish("access.grant", envelope); err != nil {
+		return fmt.Errorf("failed to enqueue access grant: %w", err)
+	}
+	return nil
+}
+
+func (bus *Bus) RevokeAccess(request *RevokeAccess) error {
+	envelope := request // TODO
+	if err := bus.NATS.Publish("access.revoke", envelope); err != nil {
+		return fmt.Errorf("failed to enqueue access revocation: %w", err)
+	}
+	return nil
+}