package node import ( "mediarr/cluster" "mediarr/database" ) type Node struct { db database.DatabaseClient clusterKeyPath string cluster cluster.Identity } type NewNodeParams struct { DatabaseName string ClusterKeyPath string } func NewNode(params NewNodeParams) (error, Node) { var databaseName *string if params.DatabaseName != "" { databaseName = ¶ms.DatabaseName } err, db := database.NewDatabase(database.NewDatabaseParams{ DatabaseName: databaseName, }) if err != nil { return err, Node{} } clusterKeyPath := params.ClusterKeyPath if clusterKeyPath == "" { clusterKeyPath = "cluster.key" } return nil, Node{ db: *db, clusterKeyPath: clusterKeyPath, } } func (n *Node) Close() error { return n.db.Close() } func (n *Node) ClusterIdentity() cluster.Identity { return n.cluster }