examples

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: UPL-1.0 Imports: 10 Imported by: 0

Documentation

Overview

Package examples provides common functions used by the examples that are in sub folders.

To build the examples, use the command:

cd nosql-go-sdk
make build-examples

If build succeeds, the example binaries "basic", "delete" and "index" can be found at the nosql-go-sdk/bin/examples directory.

The examples can run with the Oracle NoSQL Cloud Simulator, the Oracle NoSQL Cloud Service and the Oracle NoSQL Database on-premise.

1. Run examples against the Oracle NoSQL Cloud Simulator.

(1) Download the Oracle NoSQL Cloud Simulator and start an instance of the Cloud Simulator. See https://docs.oracle.com/en/cloud/paas/nosql-cloud/csnsd/download-oracle-nosql-cloud-simulator.html for more details.

(2) Assume the Cloud Simulator is running at localhost:8080, use the command:

cd nosql-go-sdk/bin/examples
# Run the basic example.
# To run other examples, replace "basic" with the desired example binary.
./basic localhost:8080

2. Run examples against the Oracle NoSQL Cloud Service with IAM configuration.

(1) Create an IAM configuration file (e.g. ~/.oci/config). See https://docs.cloud.oracle.com/iaas/Content/API/Concepts/sdkconfig.htm for the format and contents of an IAM configuration file.

[DEFAULT]
user=ocid1.user.oc1..aaaaaaaa65vwl75tewwm32rgqvm6i34unq
fingerprint=20:3b:97:13:55:1c:5b:0d:d3:37:d8:50:4e:c5:3a:34
key_file=~/.oci/oci_api_key.pem
pass_phrase=examplephrase
tenancy=ocid1.tenancy.oc1..aaaaaaaaba3pv6wuzr4h25vqstifsfdsq
region=us-ashburn-1

(2) Assume the Oracle NoSQL Cloud Service is running at the US East (Ashburn) region, the corresponding region id is "us-ashburn-1", use the command:

cd nosql-go-sdk/bin/examples
# Run the basic example.
# To run other examples, replace "basic" with the desired example binary
#
# usage 1:
# Use the "DEFAULT" profile from the default configuration file ~/.oci/config.
# Note the region id must be specified in that profile.
./basic -config=cloud
#
# usage 2:
# Use the "DEFAULT" profile from a file other than ~/.oci/config, and
# specify the region id on command line:
./basic -config=cloud -configFile=/path/to/iam_config us-ashburn-1
#
# usage 3:
# You may also include -iamProfileID=<profile> to use a profile other
# than "DEFAULT", and/or include -iamCompartmentID=<compartmentOCID> to
# use a compartment ID other than the "tenancy" OCID from the IAM config file.
./basic -config=cloud -configFile=/path/to/iam_config -iamProfileID=profile -iamCompartmentID=comp_id us-ashburn-1

3. Run examples against the Oracle NoSQL Database on-premise.

(1) Download the Oracle NoSQL Database Server and Oracle NoSQL Database Proxy (aka HTTP Proxy) at https://www.oracle.com/database/technologies/nosql-database-server-downloads.html. Start an instance of the HTTP Proxy that connects to the Oracle NoSQL Database Server.

(2) If the Oracle NoSQL Database Server has security configuration enabled, create a configuration file that specifies the username and password used to authenticate with the server, for example (~/kvstore_config):

username=user1
password=NoSql00__123456

(3) Assume the HTTP Proxy is running at https://localhost:8080, use the command to run examples against the Oracle NoSQL Database Server that has security configuration enabled:

cd nosql-go-sdk/bin/examples
# Run the basic example.
# To run other examples, replace "basic" with the desired example binary.
./basic -config=onprem -configFile=~/kvstore_config https://localhost:8080

Assume the HTTP Proxy is running at http://localhost:8080, use the command to run examples against the Oracle NoSQL Database Server that has security configuration disabled:

cd nosql-go-sdk/bin/examples
# Run the basic example.
# To run other examples, replace "basic" with the desired example binary.
./basic -config=onprem localhost:8080

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateClient

func CreateClient() (client *nosqldb.Client, err error)

CreateClient creates a client using the configurations from command line arguments supplied by user.

func RunQuery

func RunQuery(client *nosqldb.Client, query string) (results []*types.MapValue, err error)

RunQuery executes a query in a loop to be sure that all results have been returned. This function returns a single list of results, which is not recommended for queries that return a large number of results.

This function mostly demonstrates the need to loop if a query result includes a continuation key. This is a common occurrence because each query request will only read a limited amount of data before returning a response. It is valid, and expected that a query result can have a continuation key but not contain any actual results. This occurs if the read limit is reached before any results match a predicate in the query. It is also expected for count(*) types of queries.

NOTE: for better performance and less throughput consumption prepared queries should be used.

Types

This section is empty.

Directories

Path Synopsis
The basic example shows how to perform basic operations on an Oracle NoSQL table.
The basic example shows how to perform basic operations on an Oracle NoSQL table.
The delete example shows how to delete a row or multiple rows satisfying certain criteria from a table.
The delete example shows how to delete a row or multiple rows satisfying certain criteria from a table.
The index example shows how to create and use the index on a table.
The index example shows how to create and use the index on a table.

Jump to

Keyboard shortcuts

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