add readme, now the driver is ok!

This commit is contained in:
alexisvisco 2019-03-25 20:34:14 +01:00
parent 7dd0faf24b
commit 95120c77b1
6 changed files with 145 additions and 29 deletions

View file

@ -3,28 +3,28 @@ package main
import (
"fmt"
"github.com/expectedsh/go-sonic/sonic"
"time"
)
func main() {
connection := &sonic.Connection{
Host: "localhost",
Port: 1491,
Password: "SecretPassword",
Channel: sonic.Ingest,
ingester, err := sonic.NewIngester("localhost", 1491, "SecretPassword")
if err != nil {
panic(err)
}
e := connection.Connect()
if e != nil {
panic(e)
// I will ignore all errors for demonstration purposes
_ = ingester.Push("movies", "general", "id:6ab56b4kk3", "Star wars")
_ = ingester.Push("movies", "general", "id:5hg67f8dg5", "Spider man")
_ = ingester.Push("movies", "general", "id:1m2n3b4vf6", "Batman")
_ = ingester.Push("movies", "general", "id:68d96h5h9d0", "This is another movie")
search, err := sonic.NewSearch("localhost", 1491, "SecretPassword")
if err != nil {
panic(err)
}
channel := sonic.IngesterChannel{Connection: connection}
c, e := channel.Count("test", "default", "captain")
fmt.Println("waiting")
time.Sleep(time.Second * 10)
e = channel.Ping()
//c, e = channel.Count("test", "default", "captain")
results, _ := search.Query("movies", "general", "man", 10, 0)
fmt.Println(c, e)
fmt.Println(results)
}