client

package
v0.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 26, 2016 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Date

func Date(date time.Time) (*graph.Value, error)

func Datetime

func Datetime(date time.Time) (*graph.Value, error)

func Uid

func Uid(uid uint64) string

Uid converts an uint64 to a string, which can be used as part of Subject and ObjectId fields in the graph.NQuad

func ValueFromGeoJson

func ValueFromGeoJson(json string) (*graph.Value, error)

loc, err := client.ValueFromGeoJson(`{"type":"Point","coordinates":[-122.2207184,37.72129059]}`)

if err != nil {
	log.Fatal(err)
}
if err := req.AddMutation(graph.NQuad{
	Subject:     "alice",
	Predicate:   "birthday",
	ObjectValue: loc,
}, client.SET); err != nil {
	log.Fatal(err)
}

Types

type BatchMutation

type BatchMutation struct {
	// contains filtered or unexported fields
}

func NewBatchMutation

func NewBatchMutation(ctx context.Context, conn *grpc.ClientConn,
	size int, pending int) *BatchMutation

func (*BatchMutation) AddMutation

func (batch *BatchMutation) AddMutation(nq graph.NQuad, op Op) error

func (*BatchMutation) Counter

func (batch *BatchMutation) Counter() Counter

func (*BatchMutation) Flush

func (batch *BatchMutation) Flush()

type Counter

type Counter struct {
	Rdfs      uint64
	Mutations uint64
	Elapsed   time.Duration
}

type Op

type Op int
const (
	SET Op = iota
	DEL
)

type Req

type Req struct {
	// contains filtered or unexported fields
}

Req wraps the graph.Request so that we can define helper methods for the client around it.

func (*Req) AddMutation

func (req *Req) AddMutation(nq graph.NQuad, op Op) error

To add a mutation with a DELETE operation

if err := req.AddMutation(graph.NQuad{
	Sub:   "alice",
	Pred:  "name",
	Value: client.Str("Alice"),
}, client.DEL); err != nil {

.... handle error .... }

func (*Req) Request

func (req *Req) Request() *graph.Request

Request returns the graph request object which is sent to the server to perform a query/mutation.

func (*Req) SetQuery

func (req *Req) SetQuery(q string)

SetQuery sets a query as part of the request. Example usage req := client.Req{} req.SetQuery("{ me(_xid_: alice) { name falls.in } }") resp, err := c.Query(context.Background(), req.Request()) Check response and handle errors

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL