dbsync2

command module
v0.0.0-...-d076d71 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

README

Sync Client V2

The Sync Client can be used to transfer all updates on contacts to an SQL database or a web service.

Activation

To be able to use the Sync Client, activate the corresponding connector in the campaign settings. After successful activation, a token is displayed below the connectors. It is required to use the client. The token is only visible to the user who activated the connector.

Alternativtext wenn Bild nicht gefunden

Installation

Download the latest version of the binary
Installation of the bindary from our Personal Packet Archive (PPA)

Add archive as package source

sudo add-apt-repository ppa:cloud-it/ppa && sudo apt update

Install Sync Client

sudo apt install dbsync2
Alternative Installation

Add archive as package source

sudo echo "deb http://ppa.launchpad.net/cloud-it/ppa/ubuntu bionic main" >> /etc/apt/sources.list
sudo echo "deb-src http://ppa.launchpad.net/cloud-it/ppa/ubuntu bionic main" >> /etc/apt/sources.list

Import signature key

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 441418A3042CED3E4CEAB3679F70A4F921F821F6

Install Sync Client

sudo apt-get update && apt-get install dbsync2
Download and compile source code

Install Git

sudo apt-get install git

Install Google Go

sudo apt-get install golang-go

For the further steps it is necessary that the environment variable GOPATH is set. A description of how to set the GOPATH environment variable correctly can be found here.

Clone the repository

go get bitbucket.org/modima/dbsync2

Install all dependencies

cd $GOPATH/src/bitbucket.org/modima/dbsync && godep restore

Compile the source code

  • Target platform Linux

    cd $GOPATH/src/bitbucket.org/modima/dbsync2/ && go build
    
  • Target platform Windows

    cd $GOPATH/src/bitbucket.org/modima/dbsync2/ && GOOS=windows GOARCH=amd64 go build -o dbsync2.exe
    
  • Target platform Mac

    cd $GOPATH/src/bitbucket.org/modima/dbsync2/ && GOOS=darwin GOARCH=amd64 go build -o dbsync2_mac
    

How it works

All updates on contacts are loaded every minute and then transferred directly to the web service or database.

Usage

SQL database

The client currently supports the following database systems:

  • MySQL / MariaDB
  • PostgreSQL
  • Microsoft SQL Server

Before you can use the client with a database, the corresponding database must be created.

The client creates the following 4 tables within that database:

  • contacts
    • Contains all $ fields, as well as the first 100 custom fields of the campaign.
  • transactions
    • Contains all transactions and the foreign key contact_id on the corresponding contact.
  • connections
    • Contains all connections of the transaction and the foreign key transaction_id to the corresponding transaction.
  • recordings
    • Contains all call recordings of the connection and the foreign key connection_id to the corresponding connection.
  • inbound_calls
    • Contains all inbound calls and the foreign key contact_id to the corresponding contact

Alternativtext wenn Bild nicht gefunden

Database Connection URL Schema
MySQL / MariaDB:
mysql://username:password@localhost:3306/database?useSSL=false
PostgreSQL:
postgres://username:password@localhost:5432/database?sslmode=disable
Microsoft SQL Server:
sqlserver://username:password@localhost:1433/instance/database
Example

Transfer all transactions from 01 February 2018 in the campaign MY_CAMPAIGN to a local running instance of Microsoft SQL Server. Only updates that begin with the prefix 'fc_' or 'qc_' in campaign stages and have been performed by a user are to be transferred.

dbsync2 --a db_sync --fm hi_updates_only --fp 'fc_,qc_' --c MY_CAMPAIGN_ID --ct MY_CAMPAIGN_TOKEN --s 2018-02-01 --url sqlserver://my_user:my_password@localhost:1433/sql_server_instance/my_database
Web service

As an alternative to a database, the transactions can be forwarded to a web service. The service must accept POST requests and answer the successful receipt of the data with a status code between 200 and 299. Otherwise, the data will be resent (maximum 10 attempts).

The sent payload has the following JSON format:

{
    "contact":...,      
    "transaction":...,  
    "state":...,
}
  • contact
    • contains the contact details
  • transaction
    • Contains the corresponding transaction
  • state
    • new ... for a new transaction
    • updated ... When the transaction is updated (for example, the connection data is added later).
Example

Transfer all future transactions in the campaign MY_CAMPAIGN to a Webservice.

./dbsync --a webhook --c MY_CAMPAIGN_ID --ct MY_CAMPAIGN_TOKEN --url 'https://example.com/api/transactions/'
(Error) protocol
  • All error messages are written directly to the console (stdout).
  • All log messages are written to /var/log/dbsync/{MY_CAMPAIGN_ID}_{MODE}_{TIMESTAMP}.log.
  • If the directory /var/log/ is locked, then the messages appear under $HOME/.dbsync/logs/{MY_CAMPAIGN_ID}_{MODE}_{TIMESTAMP}.log.
Command line options

An overview of all options can be obtained with the following command.

dbsync --help

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package logging implements a logging infrastructure for Go.
Package logging implements a logging infrastructure for Go.
spf13/pflag
Package pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
Package pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
maps
Package maps provides reusable functions for manipulating nested map[string]interface{} maps are common unmarshal products from various serializers such as json, yaml etc.
Package maps provides reusable functions for manipulating nested map[string]interface{} maps are common unmarshal products from various serializers such as json, yaml etc.
providers/env
Package env implements a koanf.Provider that reads environment variables as conf maps.
Package env implements a koanf.Provider that reads environment variables as conf maps.
providers/posflag
Package posflag implements a koanf.Provider that reads commandline parameters as conf maps using spf13/pflag, a POSIX compliant alternative to Go's stdlib flag package.
Package posflag implements a koanf.Provider that reads commandline parameters as conf maps using spf13/pflag, a POSIX compliant alternative to Go's stdlib flag package.
Package mapstructure exposes functionality to convert an arbitrary map[string]interface{} into a native Go structure.
Package mapstructure exposes functionality to convert an arbitrary map[string]interface{} into a native Go structure.
Package pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.
Package pflag is a drop-in replacement for Go's flag package, implementing POSIX/GNU-style --flags.

Jump to

Keyboard shortcuts

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