tree: f30fa52392505d99cd1e42ededafdbd002173849 [path history] [tgz]
  1. admin/
  2. docs/
  3. example/
  4. generator/
  5. idl/
  6. integration/
  7. pegalog/
  8. pegasus/
  9. rpc/
  10. session/
  11. .golangci.yml
  12. codecov.yml
  13. go.mod
  14. go.sum
  15. Makefile
  16. README.md
  17. test.sh
go-client/README.md

pegasus-go-client

Go Report Card

Requirement

Go1.14+.

Logging

By default pegasus-go-client logs to “./pegasus.log” on where your application runs. You can customize the logging rules as follows:

    // customize where the pegasus-go-client's logs reside.
    pegalog.SetLogger(pegalog.NewLogrusLogger(&pegalog.LogrusConfig{
        // rotation rules
        MaxSize:    500, // megabytes
        MaxAge:     5,   // days
        MaxBackups: 100,
        // log files location
        Filename:   "/home/work/myapp/log/pegasus.log",
    }))

To print the logs on screen:

pegalog.SetLogger(pegalog.StderrLogger)

We highly recommend you to enable client logging for debugging purpose. If you want support for other log destinations or log formats, please submit an issue for that.

Example

    import (
        "context"

        "github.com/apache/incubator-pegasus/go-client/pegasus"
    )

    cfg := Config{
        MetaServers: []string{"0.0.0.0:34601", "0.0.0.0:34602", "0.0.0.0:34603"},
    }

    client := NewClient(cfg)
    defer client.Close()

    tb, err := client.OpenTable(context.Background(), "temp")
    err = tb.Set(context.Background(), []byte("h1"), []byte("s1"), []byte("v1"))

For more examples please refer to example/.

TroubleShooting

Before using pegasus-go-client, it's recommended to configure GOBACKTRACE so as to generate coredump while program unexpectedly corrupts.

ulimit -c unlimited
export GOBACTRACE=crash