コード例 #1
0
ファイル: config_test.go プロジェクト: datagentleman/puaro
func ExampleConfig_FromFile() {
	config, err := puaro.ConfigFromFile("./fixtures/config.json")
	if err != nil {
		fmt.Printf("%s\n", err)
	}

	fmt.Printf("%s\n", config["worker:status"])
	fmt.Printf("%s\n", config["dataset:main"])

	// Output:
	// active
	// tcp:9999
}
コード例 #2
0
ファイル: instance_test.go プロジェクト: datagentleman/puaro
func ExampleInstance_Create() {
	config, _ := puaro.ConfigFromFile("../../configs/test.json")
	ds := &storage.Dataset{Name: "Iris"}

	attrs := &instance.Attributes{
		"attr1": "value1",
		"attr2": "value2",
		"attr3": "value3",
	}

	ps := httprouter.Params{
		httprouter.Param{"dataset", "iris"},
		httprouter.Param{"collection", "satosa"},
	}

	params, _ := marshaller.IoReader(attrs)
	req, _ := http.NewRequest("POST", "/", params)

	db, _ := redis.NewDB(config)
	storage := storage.New(db)

	storage.Clean()

	if err := storage.Insert(ds); err != nil {
		fmt.Printf("%s\n", err)
		return
	}

	instance := api.InstanceHandler{storage}
	resp := httptest.NewRecorder()
	instance.Create(resp, req, ps)

	fmt.Printf("RESPONSE CODE: %d\n", resp.Code)

	// Output:
	// RESPONSE CODE: 200
}
コード例 #3
0
ファイル: dataset_test.go プロジェクト: datagentleman/puaro
	"fmt"
	"net/http"
	"net/http/httptest"

	"github.com/datagentleman/gems/storage"
	"github.com/datagentleman/gems/storage/db/redis"

	"github.com/datagentleman/puaro"

	"github.com/datagentleman/puaro/marshaller"
	"github.com/datagentleman/puaro/unmarshaller"
	"github.com/datagentleman/puaro/warehouse/api"
)

var (
	config, err = puaro.ConfigFromFile("../../configs/test.json")
)

func init() {
	if err != nil {
		fmt.Printf("%s\n", err)
	}
}

func ExampleDataset_Create() {
	ds := &storage.Dataset{Name: "Iris"}
	params, _ := marshaller.IoReader(ds)
	req, _ := http.NewRequest("POST", "/datasets/", params)

	db, _ := redis.NewDB(config)
	storage := storage.New(db)