Ejemplo n.º 1
0
func sprintCounts(counts map[mcd.CommandCode]int) string {
	line := ""
	for i := 0; i < 256; i++ {
		opcode := mcd.CommandCode(i)
		if n, ok := counts[opcode]; ok {
			line += fmt.Sprintf("%s:%v ", mcd.CommandNames[opcode], n)
		}
	}
	return strings.TrimRight(line, " ")
}
Ejemplo n.º 2
0
func addToMap(m map[string]uint64, i int, counters [257]uint64) {
	v := atomic.LoadUint64(&counters[i])
	if v > 0 {
		k := "unknown"
		if i < 256 {
			k = gomemcached.CommandCode(i).String()
		}
		m[k] = v
		m["total"] += v
	}
}
Ejemplo n.º 3
0
// TODO:
//  performance consideration,
//      try to adjust buffer size for feed.C channel

import (
	"encoding/binary"
	"fmt"
	mcd "github.com/couchbase/gomemcached"
	mc "github.com/couchbase/gomemcached/client"
	"log"
	"time"
)

// constants used for memcached protocol
const (
	uprOPEN        = mcd.CommandCode(0x50) // Open a upr connection with `name`
	uprAddSTREAM   = mcd.CommandCode(0x51) // Sent by ebucketmigrator to upr consumer
	uprCloseSTREAM = mcd.CommandCode(0x52) // Sent by ebucketmigrator to upr consumer
	uprFailoverLOG = mcd.CommandCode(0x54) // Request all known failover ids for restart
	uprStreamREQ   = mcd.CommandCode(0x53) // Stream request from consumer to producer
	uprStreamEND   = mcd.CommandCode(0x55) // Sent by producer when it is going to end stream
	uprSnapshotM   = mcd.CommandCode(0x56) // Sent by producer for a new snapshot
	uprMUTATION    = mcd.CommandCode(0x57) // Notifies SET/ADD/REPLACE/etc.  on the server
	uprDELETION    = mcd.CommandCode(0x58) // Notifies DELETE on the server
	uprEXPIRATION  = mcd.CommandCode(0x59) // Notifies key expiration
	uprFLUSH       = mcd.CommandCode(0x5a) // Notifies vbucket flush
)
const (
	rollBack = mcd.Status(0x23)
)
Ejemplo n.º 4
0
	"github.com/couchbase/cbauth"
	"github.com/couchbase/go-couchbase"
	mc "github.com/couchbase/gomemcached"
	mcc "github.com/couchbase/gomemcached/client"
	"net"
	"net/http"
	"net/url"
	"strconv"
	"strings"
	"time"

	log "github.com/couchbase/clog"
)

// opcode for memcached audit command
var AuditPutCommandCode = mc.CommandCode(0x27)

// write timeout
var WriteTimeout = 1000 * time.Millisecond

// read timeout
var ReadTimeout = 1000 * time.Millisecond
var PoolClients = 5

type GenericFields struct {
	Timestamp  string     `json:"timestamp"`
	RealUserid RealUserId `json:"real_userid"`
}

type RealUserId struct {
	Source   string `json:"source"`