client

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

README

Go Actions Status

geode-go

geode-go provides Go package for connecting with Apache Geode.

Inspired by

Install

go get -u github.com/davinash/geode-go

Region APIs Supported

  • Put
  • Get
  • PutAll
  • GetAll
  • PutIfAbsent
  • Remove
  • Size
  • Clear

Function Execution

  • ExecuteFunctionOnRegion
  • ExecuteFunctionOnMember

API Usage

Create a new client
geodeClient, err := client.NewClient(100)
Add a Server to this client
err := geodeClient.AddServer("localhost", port)
if err != nil {
    return err
}
Put Operation
geodeClient.Region(regionName).Put("Key", "Value")
Get Operation
geodeClient.Region(regionName).Get("Key")
Size
geodeClient.Region(regionName).Size()
KeySet
geodeClient.Region(regionName).KeySet()
PutIfAbsent
geodeClient.Region(regionName).PutIfAbsent("Key-1", "Value-New")
PutAll
kvs := make([]*pkg.KeyValue, 0)
for i := 0; i < 10; i++ {
    kvs = append(kvs, &pkg.KeyValue{
        Key:   fmt.Sprintf("Key-PutAll-%d", i),
        Value: fmt.Sprintf("Val-PutAll-%d", i),
    })
}
putAll, err := suite.Client.Region(regionName).PutAll(kvs)
if err != nil {
    log.Println("PutAll failed, Error =  %v", err)
}
GetAll
keys := make([]*pkg.Keys, 0)
for i := 0; i < 10; i++ {
    keys = append(keys, &pkg.Keys{
        Key: fmt.Sprintf("Key-PutAll-%d", i),
    })
}
values, err := suite.Client.Region(regionName).GetAll(keys)
if err != nil {
    log.Println("GetAll failed, Error = %v", err)
}
Remove
geodeClient.Region(regionName).Remove(key)
Clear
geodeClient.Region(regionName).Clear()

Documentation

Overview

Client package provides to create client and entry point for this go package

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GeodeClient

type GeodeClient struct {
	Pool *pkg.Pool
}

func NewClient

func NewClient(maxConn int) (*GeodeClient, error)

NewClient Creates a new client, maxConn is maximum number of connection this instance of client will open

func (*GeodeClient) AddServer

func (g *GeodeClient) AddServer(host string, port int) error

AddServer Add new server for this client to connect

func (*GeodeClient) Disconnect

func (g *GeodeClient) Disconnect()

Disconnect disconnect current connection

func (*GeodeClient) FunctionService

func (g *GeodeClient) FunctionService() *pkg.Function

func (*GeodeClient) GetRegionNames

func (g *GeodeClient) GetRegionNames() ([]string, error)

GetRegionNames Gets all the regions created in a cluster

func (*GeodeClient) Region

func (g *GeodeClient) Region(s string) *pkg.Region

Region Creates a instance of a new Region

Directories

Path Synopsis
pb

Jump to

Keyboard shortcuts

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