asc

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2018 License: Apache-2.0 Imports: 19 Imported by: 0

README

Datastore Connectivity for Aerospike (asc)

Datastore Connectivity library for Aerospike in Go. GoDoc

This library is compatible with Go 1.5+

Please refer to CHANGELOG.md if you encounter breaking changes.

Usage:

The following is a very simple example of CRUD operations with dsc

package main

import (
    _ "github.com/aerospike/aerospike-client-go"
    _ "github.com/viant/asc"
)


type Interest struct {
	Id int	`autoincrement:"true"`
	Name string
	ExpiryTimeInSecond int `column:"expiry"`
	Category string
}


func main() {

	config := dsc.NewConfig("aerospike", "", "host:127.0.0.1,port:3000,namespace:test,generationColumnName:generation,dateLayout:2006-01-02 15:04:05.000")
	factory := dsc.NewManagerFactory()
	manager, err := factory.Create(config)
    if err != nil {
            panic(err.Error())
    }

  	// manager := factory.CreateFromURL("file:///etc/myapp/datastore.json")
  
    interest := Interest{}
    
    success, err:= manager.ReadSingle(&interest, "SELECT id, name, expiry, category FROM interests WHERE id = ?", []interface{}{id},nil)
	if err != nil {
        panic(err.Error())
	}

    var intersts = make([]Interest, 0)
    err:= manager.ReadAll(&interests, "SELECT id, name, expiry, category FROM interests", nil ,nil)
    if err != nil {
        panic(err.Error())
    }

    
    intersts := []Interest {
        Interest{Name:"Abc", ExpiryTimeInSecond:3600, Category:"xyz"},
        Interest{Name:"Def", ExpiryTimeInSecond:3600, Category:"xyz"},
        Interest{Id:"20, Name:"Ghi", ExpiryTimeInSecond:3600, Category:"xyz"},
    }


	inserted, updated, err:= manager.PersistAll(&intersts, "intersts", nil)
	if err != nil {
        panic(err.Error())
   	}
   	fmt.Printf("Inserted %v, updated: %v\n", inserted, updated)
  
    deleted, err := manager.DeleteAll(&intersts, "intersts", nil)
    if err != nil {
        panic(err.Error())
   	}
 	fmt.Printf("Inserted %v, updated: %v\n", deleted)
  
}

GoCover

GoCover

License

The source code is made available under the terms of the Apache License, Version 2, as stated in the file LICENSE.

Individual files may be made available under their own specific license, all compatible with Apache License, Version 2. Please see individual files for details.

Credits and Acknowledgements

Library Author: Adrian Witas

Contributors:

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadKey

func ReadKey(reader io.Reader, namespace, setName string) (*aerospike.Key, int, error)

func WriteKey

func WriteKey(key *aerospike.Key, writer io.Writer) (err error)

Types

type Batch

type Batch struct {
	Keys    []*aerospike.Key
	Records []*aerospike.Record
}

type BatchIterator

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

BatchIterator represents a helper iterator for full scan, in this case keys were scanned first from each node separately to be used by this batch iterator, after keys files are fully process they will be removed.

func NewBatchIterator

func NewBatchIterator(client *aerospike.Client, batchPolicy *aerospike.BatchPolicy, batchSize int, namespace, table string, fileNames []string, binNames ...string) *BatchIterator

func (*BatchIterator) HasNext

func (i *BatchIterator) HasNext() bool

HasNext check is has more record, if needed it will scan keys from files to batch corresponding records

func (*BatchIterator) Next

func (i *BatchIterator) Next(target interface{}) error

type KeyScanner

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

func NewKeyScanner

func NewKeyScanner(client *aerospike.Client, scanPolicy *aerospike.ScanPolicy, baseDirectory, namespace, dataSet string) *KeyScanner

func (*KeyScanner) Scan

func (s *KeyScanner) Scan() ([]string, error)

Jump to

Keyboard shortcuts

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