github.com/GeniusesGroup/libgo@v0.0.0-20220929090155-5ff932cb408e/ganjine/cluster.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package ganjine
     4  
     5  import (
     6  	"../object"
     7  	"../protocol"
     8  )
     9  
    10  // Cluster is the base datastore object that use by other part of app and platforms!
    11  // Cluster implements protocol.ObjectDirectory && protocol.
    12  // Each node in cluster and SDK in authorized app must have it to work probably.
    13  // First node of cluster is cordiantor of cluster.
    14  type Cluster struct {
    15  	State int
    16  
    17  	objects object.Directory        // Distributed object storage
    18  	files   protocol.FileDirectory  // Distributed file storage
    19  	records protocol.StorageRecords // Distributed records storage
    20  
    21  	TransactionManager TransactionManager
    22  }
    23  
    24  // Cluster State
    25  const (
    26  	ClusterStateStop int = iota
    27  	ClusterStateRunning
    28  	ClusterStateStopping
    29  	ClusterStateStarting // plan to start
    30  )
    31  
    32  func (c *Cluster) LocalObjects() protocol.StorageObjects      { return }
    33  func (c *Cluster) LocalObjectsCache() protocol.StorageObjects { return }
    34  func (c *Cluster) LocalFiles() protocol.FileDirectory         { return }
    35  func (c *Cluster) LocalRecords() protocol.StorageRecords      { return }
    36  func (c *Cluster) LocalRecordsCache() protocol.StorageRecords { return }
    37  
    38  func (c *Cluster) Objects() protocol.Objects        { return &c.objects }
    39  func (c *Cluster) Files() protocol.FileDirectory    { return c.files }
    40  func (c *Cluster) Records() protocol.StorageRecords { return c.records }
    41  
    42  // Init initialize an exiting cluster to get or make a cluster!
    43  func (c *Cluster) Init() (err protocol.Error) {
    44  	registerServices()
    45  	object.Init()
    46  
    47  	c.TransactionManager.init()
    48  
    49  	return
    50  }
    51  
    52  // Shutdown the cluster!
    53  func (c *Cluster) Shutdown() (err protocol.Error) {
    54  	// Close Indexes
    55  	// Notify other nodes
    56  	return
    57  }