mirror of
https://github.com/pikami/cosmium.git
synced 2025-03-13 05:15:52 +00:00
Stability improvements
This commit is contained in:
parent
813b9faeaa
commit
b2516eda9f
@ -90,6 +90,7 @@ func runTestsWithPreset(t *testing.T, name string, testPreset testPreset, f test
|
||||
|
||||
ts := runTestServerCustomConfig(serverConfig)
|
||||
defer ts.Server.Close()
|
||||
defer ts.DataStore.Close()
|
||||
|
||||
client, err := azcosmos.NewClientFromConnectionString(
|
||||
fmt.Sprintf("AccountEndpoint=%s;AccountKey=%s", ts.URL, config.DefaultAccountKey),
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"github.com/pikami/cosmium/internal/datastore"
|
||||
badgerdatastore "github.com/pikami/cosmium/internal/datastore/badger_datastore"
|
||||
mapdatastore "github.com/pikami/cosmium/internal/datastore/map_datastore"
|
||||
"github.com/pikami/cosmium/internal/logger"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -19,11 +20,13 @@ func main() {
|
||||
switch configuration.DataStore {
|
||||
case config.DataStoreBadger:
|
||||
dataStore = badgerdatastore.NewBadgerDataStore()
|
||||
logger.InfoLn("Using Badger data store")
|
||||
default:
|
||||
dataStore = mapdatastore.NewMapDataStore(mapdatastore.MapDataStoreOptions{
|
||||
InitialDataFilePath: configuration.InitialDataFilePath,
|
||||
PersistDataFilePath: configuration.PersistDataFilePath,
|
||||
})
|
||||
logger.InfoLn("Using in-memory data store")
|
||||
}
|
||||
|
||||
server := api.NewApiServer(dataStore, &configuration)
|
||||
|
@ -28,6 +28,7 @@ func NewBadgerDataStore() *BadgerDataStore {
|
||||
|
||||
func (r *BadgerDataStore) Close() {
|
||||
r.db.Close()
|
||||
r.db = nil
|
||||
}
|
||||
|
||||
func (r *BadgerDataStore) DumpToJson() (string, error) {
|
||||
|
@ -20,14 +20,14 @@ var (
|
||||
const (
|
||||
ResponseSuccess = 0
|
||||
|
||||
ResponseUnknown = 100
|
||||
ResponseFailedToParseConfiguration = 101
|
||||
ResponseFailedToLoadState = 102
|
||||
ResponseFailedToParseRequest = 103
|
||||
ResponseServerInstanceAlreadyExists = 104
|
||||
ResponseServerInstanceNotFound = 105
|
||||
ResponseFailedToStartServer = 106
|
||||
ResponseCurentDataStoreDoesNotSupportStateLoading = 107
|
||||
ResponseUnknown = 100
|
||||
ResponseFailedToParseConfiguration = 101
|
||||
ResponseFailedToLoadState = 102
|
||||
ResponseFailedToParseRequest = 103
|
||||
ResponseServerInstanceAlreadyExists = 104
|
||||
ResponseServerInstanceNotFound = 105
|
||||
ResponseFailedToStartServer = 106
|
||||
ResponseCurrentDataStoreDoesNotSupportStateLoading = 107
|
||||
|
||||
ResponseDataStoreNotFound = 200
|
||||
ResponseDataStoreConflict = 201
|
||||
|
@ -65,6 +65,7 @@ func StopServerInstance(serverName *C.char) int {
|
||||
|
||||
if serverInstance, ok := getInstance(serverNameStr); ok {
|
||||
serverInstance.server.Stop()
|
||||
serverInstance.dataStore.Close()
|
||||
removeInstance(serverNameStr)
|
||||
return ResponseSuccess
|
||||
}
|
||||
@ -100,7 +101,7 @@ func LoadServerInstanceState(serverName *C.char, stateJSON *C.char) int {
|
||||
}
|
||||
return ResponseSuccess
|
||||
}
|
||||
return ResponseCurentDataStoreDoesNotSupportStateLoading
|
||||
return ResponseCurrentDataStoreDoesNotSupportStateLoading
|
||||
}
|
||||
|
||||
return ResponseServerInstanceNotFound
|
||||
|
Loading…
x
Reference in New Issue
Block a user