Skip to content

Latest commit

History

History
67 lines (44 loc) 路 2.01 KB

README.md

File metadata and controls

67 lines (44 loc) 路 2.01 KB

proxysql-go Build Status codecov Documentation Go Report Card

A thread safe package for building ProxySQL sidecars in go. Modify ProxySQL's configuration and routing rules on the fly, and easily write tests for these changes.

About

Proxysql-go is a package designed to help you build your own service discovery for ProxySQL. You can update ProxySQL's configuration on the fly. While you could send SQL queries to it yourself, those are hard to mock and test. This package allows you to update it with functions, and then mock and test your code that uses these functions.

Use

Example located here

Install the package

go get github.com/kirinrastogi/proxysql-go

Import the package

import (
  . "github.com/kirinrastogi/proxysql-go" // optional "."
)

Create an instance of the client

conn, err := NewProxySQL("/")

The string should be in the DSN format

Modify ProxySQL's configuration

err := conn.AddHost(Hostname("some-hostname"), HostgroupID(1))
if err != nil {...}
err = conn.PersistChanges()
if err != nil {...}
// ProxySQL is now using your configuration!

Running Tests

You must have docker installed with privileged access.

To install code dependencies type

dep ensure -v

Then, run the tests with

go test

Alternatively, you can run tests that don't require docker with

go test -short