forked from apps/featurer
Initial commit.
This commit is contained in:
16
server/internal/services/core/datastore.go
Normal file
16
server/internal/services/core/datastore.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package core
|
||||
|
||||
import "errors"
|
||||
|
||||
// ServiceNameDatastore is a service name for data storage implementation.
|
||||
const ServiceNameDatastore = "datastore"
|
||||
|
||||
var (
|
||||
// ErrDatastore indicates that error appeared somewhere in data storage service.
|
||||
ErrDatastore = errors.New("datastore")
|
||||
// ErrDatastoreServiceIsInvalid appears when data storage implementation isn't conforming to interface.
|
||||
ErrDatastoreServiceIsInvalid = errors.New("invalid datastore implementation")
|
||||
)
|
||||
|
||||
// DataStore is an interface for data storage implementations.
|
||||
type DataStore interface{}
|
48
server/internal/services/core/datastore/datastore.go
Normal file
48
server/internal/services/core/datastore/datastore.go
Normal file
@@ -0,0 +1,48 @@
|
||||
package datastore
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
|
||||
"go.dev.pztrn.name/featurer/server/internal/application"
|
||||
"go.dev.pztrn.name/featurer/server/internal/services/core"
|
||||
)
|
||||
|
||||
type datastore struct {
|
||||
app *application.Application
|
||||
}
|
||||
|
||||
// Initialize initializes service.
|
||||
func Initialize(app *application.Application) error {
|
||||
plan := &datastore{
|
||||
app: app,
|
||||
}
|
||||
|
||||
if err := app.RegisterService(plan); err != nil {
|
||||
return fmt.Errorf("%w: %w", core.ErrDatastore, err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *datastore) ConnectDependencies() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *datastore) GetName() string {
|
||||
return core.ServiceNameDatastore
|
||||
}
|
||||
|
||||
func (p *datastore) Initialize() error {
|
||||
slog.Info("Initializing data storage...")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *datastore) LaunchStartupTasks() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (p *datastore) Shutdown() error {
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user