forked from runabol/tork
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
207 additions
and
216 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package engine | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
"github.com/runabol/tork/datastore" | ||
"github.com/runabol/tork/pkg/conf" | ||
) | ||
|
||
func (e *Engine) initDatastore() error { | ||
dstype := conf.StringDefault("datastore.type", datastore.DATASTORE_INMEMORY) | ||
var ds datastore.Datastore | ||
ds, err := datastore.NewFromProvider(dstype) | ||
if err != nil && !errors.Is(err, datastore.ErrProviderNotFound) { | ||
return err | ||
} | ||
if ds != nil { | ||
e.ds = ds | ||
return nil | ||
} | ||
switch dstype { | ||
case datastore.DATASTORE_INMEMORY: | ||
ds = datastore.NewInMemoryDatastore() | ||
case datastore.DATASTORE_POSTGRES: | ||
dsn := conf.StringDefault( | ||
"datastore.postgres.dsn", | ||
"host=localhost user=tork password=tork dbname=tork port=5432 sslmode=disable", | ||
) | ||
pg, err := datastore.NewPostgresDataStore(dsn) | ||
if err != nil { | ||
return err | ||
} | ||
ds = pg | ||
default: | ||
return errors.Errorf("unknown datastore type: %s", dstype) | ||
} | ||
e.ds = ds | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.