Initial commit

This commit is contained in:
2022-09-05 07:27:52 +02:00
commit 3699479c5e
19 changed files with 2730 additions and 0 deletions

30
storage/storage.go Normal file
View File

@@ -0,0 +1,30 @@
package storage
import (
"fmt"
"github.com/spf13/viper"
)
type Storage interface {
CreateEvent(Event) error
GetEvent(string) (*Event, error)
GetEvents(namespaces []string) ([]Event, error)
AddSubscriber(eventid string, subscriber string) error
}
type StorageImpl struct {
}
func NewStorage(cfg *viper.Viper) (Storage, error) {
var (
storage_type = cfg.GetString("storage.db.type")
)
switch storage_type {
case "mongodb":
s, err := NewMongoDBStorage(cfg)
return s, err
default:
return nil, fmt.Errorf("storage type %v is not supported", storage_type)
}
}