Extending Tork

Datastore

The Datastore component is responsible for holding metadata about jobs, tasks and worker nodes.


Types

Out of the box, Tork supports Postgres as a Datastore implementation.

Registering a custom Datastore

To register a custom Datastore implementation follow the instructions on the Extending Tork guide to get Tork running in embedded mode.

Update your main function to make use of the engine.RegisterDatastoreProvider hook:

func main() {
	if err := conf.LoadConfig(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	engine.RegisterDatastoreProvider("mydb", func() (datastore.Datastore, error) {
        // example of using config
        // url := conf.String("datastore.mydb.url")
		return nil, errors.New("not implemented yet")
	})

	if err := cli.New().Run(); err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}

Update your config file to make use of your implementation:

[datastore]
type = mydb

[datastore.mydb]
url = mydb://user@password:localhost
Previous
Intro
Next
Broker