client

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2023 License: MIT Imports: 15 Imported by: 0

README

client

import "github.com/kudzutechnologies/analytics/client"
Kudzu RPC Client for pushing analytics data

This package implements the gRPC analytics client package that can be used for implementing embedded analytics forwardrs to the Kudzu Analytis platform.

Example

package main

import (
	"github.com/kudzutechnologies/analytics/api"
	"github.com/kudzutechnologies/analytics/client"
)

func main() {
	// Create a client
	c := client.CreateAnalyticsClient(client.AnalyticsClientConfig{
		ClientId:  "1122334455667788",
		ClientKey: "11223344556677889900aabbccddeeff",
	})

	// Connect to the server
	err := c.Connect()
	if err != nil {
		panic(err)
	}

	// Push analytics data
	metrics := &api.AnalyticsMetrics{}
	err = c.PushMetrics(metrics)
	if err != nil {
		panic(err)
	}

	// Disconnect the client
	c.Disconnect()
}

Index

Variables

var (
    // An error thrown when trying to use the client while not connected
    NotConnectedError = fmt.Errorf("Client is not connnected")
)

type AnalyticsClientConfig

Configuration parameters that can be passed to the analytics client

type AnalyticsClientConfig struct {
    // The API client ID & Key for signing in
    ClientId  string `json:"client_id"`
    ClientKey string `json:"client_key"`

    // The endpoint to use for uploading the data (Optional)
    Endpoint string `json:"endpoint,omitempty"`
    // The server CA certificate file to use for validating the connection (Optional)
    CAFile string `json:"ca_file,omitempty"`
    // The default timeout for connecting (seconds)
    ConnectTimeout int32 `json:"connect_timeout,omitempty"`
    // The default timeout for all the requests (seconds)
    RequestTimeout int32 `json:"request_timeout,omitempty"`
    // The maximum re-connection back-off (seconds)
    MaxReconnectBackoff int32 `json:"max_reconnect_backoff,omitempty"`
    // Wether or not to automatically re-connect to the server
    AutoReconnect *bool `json:"reconnect,omitempty"`
}

type Client

the RPC client

type Client struct {
    // contains filtered or unexported fields
}
func CreateAnalyticsClient
func CreateAnalyticsClient(config AnalyticsClientConfig) *Client
Create an instance of the analytics client

The client will not be connected until you call the .Connect method.

func (*Client) Connect
func (c *Client) Connect() error
func (*Client) Disconnect
func (c *Client) Disconnect() error
func (*Client) PushMetrics
func (c *Client) PushMetrics(metrics *api.AnalyticsMetrics) error

Pushes analyics metrics to the service

Generated by gomarkdoc

Documentation

Overview

Kudzu RPC Client for pushing analytics data

This package implements the gRPC analytics client package that can be used for implementing embedded analytics forwardrs to the Kudzu Analytis platform.

Example
package main

import (
	"github.com/kudzutechnologies/analytics/api"
	"github.com/kudzutechnologies/analytics/client"
)

func main() {
	// Create a client
	c := client.CreateAnalyticsClient(client.AnalyticsClientConfig{
		ClientId:  "1122334455667788",
		ClientKey: "11223344556677889900aabbccddeeff",
	})

	// Connect to the server
	err := c.Connect()
	if err != nil {
		panic(err)
	}

	// Push analytics data
	metrics := &api.AnalyticsMetrics{}
	err = c.PushMetrics(metrics)
	if err != nil {
		panic(err)
	}

	// Disconnect the client
	c.Disconnect()
}
Output:

Index

Examples

Constants

View Source
const ClientVersion = 2

Revision: v1 - First public release of the client v2 - Added support for multiple antennas

Variables

View Source
var (
	// An error thrown when trying to use the client while not connected
	NotConnectedError = fmt.Errorf("Client is not connnected")
)

Functions

This section is empty.

Types

type AnalyticsClientConfig

type AnalyticsClientConfig struct {
	// The API client ID & Key for signing in
	ClientId  string `json:"client_id"`
	ClientKey string `json:"client_key"`

	// The endpoint to use for uploading the data (Optional)
	Endpoint string `json:"endpoint,omitempty"`
	// The server CA certificate file to use for validating the connection (Optional)
	CAFile string `json:"ca_file,omitempty"`
	// The default timeout for connecting (seconds)
	ConnectTimeout int32 `json:"connect_timeout,omitempty"`
	// The default timeout for all the requests (seconds)
	RequestTimeout int32 `json:"request_timeout,omitempty"`
	// The maximum re-connection back-off (seconds)
	MaxReconnectBackoff int32 `json:"max_reconnect_backoff,omitempty"`
	// Wether or not to automatically re-connect to the server
	AutoReconnect *bool `json:"reconnect,omitempty"`
	// Indicates that we are forwarding data from the server-side
	ServerSide *bool `json:"server_side,omitempty"`
}

Configuration parameters that can be passed to the analytics client

type Client

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

the RPC client

func CreateAnalyticsClient

func CreateAnalyticsClient(config AnalyticsClientConfig) *Client

Create an instance of the analytics client

The client will not be connected until you call the .Connect method.

func (*Client) Connect

func (c *Client) Connect() error

func (*Client) Disconnect

func (c *Client) Disconnect() error

func (*Client) PushMetrics

func (c *Client) PushMetrics(metrics *api.AnalyticsMetrics) error

Pushes analyics metrics to the service

Jump to

Keyboard shortcuts

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