rcutils

package module
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

README

rcutils

A simple library of code to parse the logs returned from Redis Cloud into structs. Contains parsers for both the database and the system log exports.

Examples

package main

import (
    "log"
    "os"

    "github.com/dimchansky/utfbom"
    "github.com/goslogan/rcutils"
)


func main() {

    if reader, err := os.Open("databases.csv"); err != nil {
            log.Fatalf("Unable to open databases.csv - %v", err)
    } else if databases, err := rcutils.Databases(utfbom.SkipOnly(reader)); err != nil {
            log.Fatalf("Unable to parse databases.csv - %v", err)
    } else {
        // PROCESS DATABASE OUTPUT
    }
}
package main

import (
    "log"
    "os"

    "github.com/dimchansky/utfbom"
    "github.com/goslogan/rcutils"
)


func main() {

    if reader, err := os.Open("system_log.csv"); err != nil {
            log.Fatalf("Unable to open system_log.csv - %v", err)
    } else if events, err := rcutils.SystemLog(utfbom.SkipOnly(reader), func(e *rcutils.LogEvent) bool { return e.Activity == "Configuration" }); err != nil {
            log.Fatalf("Unable to parse system_log.csv - %v", err)
    } else {
        // PROCESS CONFIG EVENTSs
    }
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBInfo

type DBInfo struct {
	Status           string  `csv:"Status"`
	DatabaseId       string  `csv:"Database ID"`
	DatabaseName     string  `csv:"Database name"`
	SubscriptionId   string  `csv:"Subscription ID"`
	SubscriptionName string  `csv:"Subscription name"`
	PublicEndpoint   string  `csv:"Public endpoint"`
	PrivateEndpoint  string  `csv:"Private endpoint"`
	MemoryLimit      float32 `csv:"Memory limit (MB)"`
	MemoryUsed       float32 `csv:"Memory used (MB)"`
	Throughput       string  `csv:"Throughput (Ops/sec)"` // Contains commas in values
	Modules          string  `csv:"Modules"`
	Options          string  `csv:"Options"`
	ShardType        string  `csv:"Shard type"`
	ShardCount       int     `csv:"Shard count"`
	ShardPrice       float32 `csv:"Shard price ($/hr)"`
	DataPriceHour    float32 `csv:"Database price ($/hr)"`
}

DBInfo represents a single line from the database export from Redis Cloud, representing information about a single database.

func Databases

func Databases(input io.Reader) ([]*DBInfo, error)

Databases parses and reads the databases export from Redis Cloud.

func (*DBInfo) GetModules

func (d *DBInfo) GetModules() []string

func (*DBInfo) GetOptions

func (d *DBInfo) GetOptions() []string

func (*DBInfo) Persistence

func (d *DBInfo) Persistence() bool

func (*DBInfo) Replication

func (d *DBInfo) Replication() bool

func (*DBInfo) Search

func (d *DBInfo) Search() bool

type LogEvent

type LogEvent struct {
	Id        int64     `csv:"id"`
	User      string    `csv:"user name"`
	Email     string    `csv:"email"`
	Activity  string    `csv:"activity"`
	TimeStamp time.Time `csv:"date"`
	Database  string    `csv:"database name"`
	Change    string    `csv:"description"`
}

LogEvent represents a single line from the system log downloaded from redis Cloud

func SystemLog

func SystemLog(source io.Reader, filter func(*LogEvent) bool) ([]*LogEvent, error)

SystemLog reads the system log downloaded from Redis Cloud and parses it into a useful format. If not all the events in the log are required, the filter function parameter can be used to exclude undesired events. If it returns false, the event will not be returned.

Jump to

Keyboard shortcuts

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