generate identity

This commit is contained in:
venture
2026-11-13 21:49:09 +01:00
parent 4da2fe9424
commit 7ebe8962dd
9 changed files with 689 additions and 5 deletions
+23 -4
View File
@@ -1,32 +1,51 @@
package node
import (
"mediarr/cluster"
"mediarr/database"
)
type Node struct {
db database.DatabaseClient
db database.DatabaseClient
clusterKeyPath string
cluster cluster.Identity
}
type NewNodeParams struct {
DatabaseName string
DatabaseName string
ClusterKeyPath string
}
func NewNode(params NewNodeParams) (error, Node) {
var databaseName *string
if params.DatabaseName != "" {
databaseName = &params.DatabaseName
}
err, db := database.NewDatabase(database.NewDatabaseParams{
DatabaseName: &params.DatabaseName,
DatabaseName: databaseName,
})
if err != nil {
return err, Node{}
}
clusterKeyPath := params.ClusterKeyPath
if clusterKeyPath == "" {
clusterKeyPath = "cluster.key"
}
return nil, Node{
db: *db,
db: *db,
clusterKeyPath: clusterKeyPath,
}
}
func (n *Node) Close() error {
return n.db.Close()
}
func (n *Node) ClusterIdentity() cluster.Identity {
return n.cluster
}