1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-04-27 13:48:49 +08:00

291 lines
6.6 KiB
Go
Raw Normal View History

// Copyright (c) Mainflux
// SPDX-License-Identifier: Apache-2.0
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
package events
import (
"context"
mfclients "github.com/mainflux/mainflux/pkg/clients"
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
"github.com/mainflux/mainflux/pkg/events"
"github.com/mainflux/mainflux/pkg/events/redis"
"github.com/mainflux/mainflux/users/clients"
"github.com/mainflux/mainflux/users/jwt"
)
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
const streamID = "mainflux.users"
var _ clients.Service = (*eventStore)(nil)
type eventStore struct {
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
events.Publisher
svc clients.Service
}
// NewEventStoreMiddleware returns wrapper around users service that sends
// events to event store.
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func NewEventStoreMiddleware(ctx context.Context, svc clients.Service, url string) (clients.Service, error) {
publisher, err := redis.NewPublisher(ctx, url, streamID)
if err != nil {
return nil, err
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
return &eventStore{
svc: svc,
Publisher: publisher,
}, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) RegisterClient(ctx context.Context, token string, user mfclients.Client) (mfclients.Client, error) {
user, err := es.svc.RegisterClient(ctx, token, user)
if err != nil {
return user, err
}
event := createClientEvent{
user,
}
if err := es.Publish(ctx, event); err != nil {
return user, err
}
return user, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) UpdateClient(ctx context.Context, token string, user mfclients.Client) (mfclients.Client, error) {
user, err := es.svc.UpdateClient(ctx, token, user)
if err != nil {
return user, err
}
return es.update(ctx, "", user)
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) UpdateClientOwner(ctx context.Context, token string, user mfclients.Client) (mfclients.Client, error) {
user, err := es.svc.UpdateClientOwner(ctx, token, user)
if err != nil {
return user, err
}
return es.update(ctx, "owner", user)
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) UpdateClientTags(ctx context.Context, token string, user mfclients.Client) (mfclients.Client, error) {
user, err := es.svc.UpdateClientTags(ctx, token, user)
if err != nil {
return user, err
}
return es.update(ctx, "tags", user)
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) UpdateClientSecret(ctx context.Context, token, oldSecret, newSecret string) (mfclients.Client, error) {
user, err := es.svc.UpdateClientSecret(ctx, token, oldSecret, newSecret)
if err != nil {
return user, err
}
return es.update(ctx, "secret", user)
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) UpdateClientIdentity(ctx context.Context, token, id, identity string) (mfclients.Client, error) {
user, err := es.svc.UpdateClientIdentity(ctx, token, id, identity)
if err != nil {
return user, err
}
return es.update(ctx, "identity", user)
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) update(ctx context.Context, operation string, user mfclients.Client) (mfclients.Client, error) {
event := updateClientEvent{
user, operation,
}
if err := es.Publish(ctx, event); err != nil {
return user, err
}
return user, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) ViewClient(ctx context.Context, token, id string) (mfclients.Client, error) {
user, err := es.svc.ViewClient(ctx, token, id)
if err != nil {
return user, err
}
event := viewClientEvent{
user,
}
if err := es.Publish(ctx, event); err != nil {
return user, err
}
return user, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) ViewProfile(ctx context.Context, token string) (mfclients.Client, error) {
user, err := es.svc.ViewProfile(ctx, token)
if err != nil {
return user, err
}
event := viewProfileEvent{
user,
}
if err := es.Publish(ctx, event); err != nil {
return user, err
}
return user, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) ListClients(ctx context.Context, token string, pm mfclients.Page) (mfclients.ClientsPage, error) {
cp, err := es.svc.ListClients(ctx, token, pm)
if err != nil {
return cp, err
}
event := listClientEvent{
pm,
}
if err := es.Publish(ctx, event); err != nil {
return cp, err
}
return cp, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) ListMembers(ctx context.Context, token, groupID string, pm mfclients.Page) (mfclients.MembersPage, error) {
mp, err := es.svc.ListMembers(ctx, token, groupID, pm)
if err != nil {
return mp, err
}
event := listClientByGroupEvent{
pm, groupID,
}
if err := es.Publish(ctx, event); err != nil {
return mp, err
}
return mp, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) EnableClient(ctx context.Context, token, id string) (mfclients.Client, error) {
user, err := es.svc.EnableClient(ctx, token, id)
if err != nil {
return user, err
}
return es.delete(ctx, user)
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) DisableClient(ctx context.Context, token, id string) (mfclients.Client, error) {
user, err := es.svc.DisableClient(ctx, token, id)
if err != nil {
return user, err
}
return es.delete(ctx, user)
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) delete(ctx context.Context, user mfclients.Client) (mfclients.Client, error) {
event := removeClientEvent{
id: user.ID,
updatedAt: user.UpdatedAt,
updatedBy: user.UpdatedBy,
status: user.Status.String(),
}
if err := es.Publish(ctx, event); err != nil {
return user, err
}
return user, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) Identify(ctx context.Context, token string) (string, error) {
userID, err := es.svc.Identify(ctx, token)
if err != nil {
return userID, err
}
event := identifyClientEvent{
userID: userID,
}
if err := es.Publish(ctx, event); err != nil {
return userID, err
}
return userID, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) GenerateResetToken(ctx context.Context, email, host string) error {
if err := es.svc.GenerateResetToken(ctx, email, host); err != nil {
return err
}
event := generateResetTokenEvent{
email: email,
host: host,
}
return es.Publish(ctx, event)
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) IssueToken(ctx context.Context, identity, secret string) (jwt.Token, error) {
token, err := es.svc.IssueToken(ctx, identity, secret)
if err != nil {
return token, err
}
event := issueTokenEvent{
identity: identity,
}
if err := es.Publish(ctx, event); err != nil {
return token, err
}
return token, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) RefreshToken(ctx context.Context, refreshToken string) (jwt.Token, error) {
token, err := es.svc.RefreshToken(ctx, refreshToken)
if err != nil {
return token, err
}
event := refreshTokenEvent{}
if err := es.Publish(ctx, event); err != nil {
return token, err
}
return token, nil
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) ResetSecret(ctx context.Context, resetToken, secret string) error {
if err := es.svc.ResetSecret(ctx, resetToken, secret); err != nil {
return err
}
event := resetSecretEvent{}
return es.Publish(ctx, event)
}
NOISSUE - Add Event Sourcing Package (#1897) * Add event sourcing package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move producer to es package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Use redis URL to configure username, password and db Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Change the redis subscriber interface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Clean up publisher inaterface Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Update redis version Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Add tests Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename factory functions of events store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Rename redis package to events package Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove unnecessary alias on redis event store Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Minor cosmetic changes Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove stream length from factory function Set the default stream length to 1e9 in the events package. This is because the stream length is not a required parameter in the factory function. This commit also removes the stream length from the factory function. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Remove group Name on subscribing Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor package consumer to reflect changes in service name The package consumer in the bootstrap/events/consumer/doc.go file has been modified to reflect the changes in the service name. The service name has been updated from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. This commit modifies the package consumer in the bootstrap/events/consumer/doc.go file to update the service name from "Things" to "Bootstrap". This change ensures that the package accurately represents the events consumer for the Bootstrap service. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Refactor main to remove go routines Remove go routines from main when subscribing to events. This is because the event handlers are already running in their own go routines. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Move cache to seperate package This commit moves the cache package to a seperate package. This is because the cache package is not the same as events package. The cache package is used to store the data in memory while the events package is used to send events to the event bus. Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> * Make startPublishingRoutine private Signed-off-by: Rodney Osodo <socials@rodneyosodo.com> --------- Signed-off-by: Rodney Osodo <socials@rodneyosodo.com>
2023-09-20 13:12:17 +03:00
func (es *eventStore) SendPasswordReset(ctx context.Context, host, email, user, token string) error {
if err := es.svc.SendPasswordReset(ctx, host, email, user, token); err != nil {
return err
}
event := sendPasswordResetEvent{
host: host,
email: email,
user: user,
}
return es.Publish(ctx, event)
}