Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

philipsoutham/gorexpro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GoRexPro

Go client for RexPro/Rexster with connection pooling as well as support for sessions. Compatable with RexPro protocol version 1 (Rexster v2.4.0 and above at the time of this writing).

Usage

import "github.com/philipsoutham/gorexpro/rexpro"

Simple

func main() {
    var properties = map[string]interface{}{"properties": map[string]interface{}{"foo": "bar", "score": 5}}
    if c, err := rexpro.Dial("your-host:8184", "your-graph-name"); err == nil {
        defer c.Close()
        if resp, err := c.DoScript("g.addVertex(properties)", properties); err == nil {
            doSomethingWith(resp)
        }
    }
}

Connection Pools

var RexproPool *rexpro.Pool

func init() {
    RexproPool = &rexpro.Pool{
		    MaxIdle:     5,
		    MaxActive:   200,
		    IdleTimeout: 25 * time.Second,
		    Dial: func() (rexpro.Conn, error) {
			    return rexpro.Dial("your-host:8184", "your-graph-name")
		    },
		    TestOnBorrow: func(c rexpro.Conn, t time.Time) error {
            _, err := c.DoScript("1", map[string]interface{}{})
			      return err
		    },
    }
}

func main() {
    var (
        c = RexproPool.Get()
        properties = map[string]interface{}{"properties": map[string]interface{}{"foo": "bar", "score": 5}}
    )
    defer c.Close()
    if resp, err := c.DoScript("g.addVertex(properties)", properties); err == nil {
        doSomethingWith(resp)
    }
}


Unit Tests

Polishing them now, so coming soon (hopefully er, maybe)

Things you should probably be aware of...

Right now, some assumptions are made in regards to the isolate parameter in the script request Meta map; that is to say that if you are in a "session", isolate will be set to false and inSession will be set to true. If you're not in a "session" the inverse will be applied. Also, the graphObjName parameter is always hardcoded to "g".

Thanks

to @garyburd as I have copied much of the API he created for his excellent redigo redis client and will be also leveraging his hard work for the unit tests as well.

About

Go client for rexpro v2.4.0, with connection pooling.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages