go-vitess.v1: gopkg.in/src-d/go-vitess.v1/vt/vtgate/gateway Index | Files

package gateway

import "gopkg.in/src-d/go-vitess.v1/vt/vtgate/gateway"

Package gateway contains the routing layer of vtgate. A Gateway can take a query targeted to a keyspace/shard/tablet_type and send it off.


Package Files

discoverygateway.go gateway.go shard_error.go status.go


const (
    StatusTemplate = "" /* 847 byte string literal not displayed */



var (

    // KeyspacesToWatch - if provided this specifies which keyspaces should be
    // visible to a vtgate. By default the vtgate will allow access to any
    // keyspace.
    KeyspacesToWatch flagutil.StringListValue

func NewShardError Uses

func NewShardError(in error, target *querypb.Target, tablet *topodatapb.Tablet) error

NewShardError returns a new error with the shard info amended.

func RegisterCreator Uses

func RegisterCreator(name string, gc Creator)

RegisterCreator registers a Creator with given name.

func WaitForTablets Uses

func WaitForTablets(gw Gateway, tabletTypesToWait []topodatapb.TabletType) error

WaitForTablets is a helper method to wait for the provided tablets, up until the *initialTabletTimeout. It will log what it is doing. Note it has the same name as the Gateway's interface method, as it just calls it.

type Creator Uses

type Creator func(ctx context.Context, hc discovery.HealthCheck, serv srvtopo.Server, cell string, retryCount int) Gateway

Creator is the factory method which can create the actual gateway object.

func GetCreator Uses

func GetCreator() Creator

GetCreator returns the Creator specified by the gateway_implementation flag.

type Gateway Uses

type Gateway interface {
    // TODO(alainjobart) The QueryService part of this interface
    // will be removed soon, in favor of the TargetStats part (that
    // returns a QueryService)

    // srvtopo.TargetStats allows this Gateway to resolve a Target
    // into a QueryService. It is used by the srvtopo.Resolver object.

    // WaitForTablets asks the gateway to wait for the provided
    // tablets types to be available. It the context is canceled
    // before the end, it should return ctx.Err().
    // The error returned will have specific effects:
    // - nil: keep going with startup.
    // - context.DeadlineExceeded: log a warning that we didn't get
    //   all tablets, and keep going with startup.
    // - any other error: log.Fatalf out.
    WaitForTablets(ctx context.Context, tabletTypesToWait []topodatapb.TabletType) error

    // RegisterStats registers exported stats for the gateway

    // CacheStatus returns a list of TabletCacheStatus per shard / tablet type.
    CacheStatus() TabletCacheStatusList

A Gateway is the query processing module for each shard, which is used by ScatterConn.

type TabletCacheStatus Uses

type TabletCacheStatus struct {
    Keyspace   string
    Shard      string
    TabletType topodatapb.TabletType
    Name       string
    Addr       string

    QueryCount uint64
    QueryError uint64
    QPS        float64
    AvgLatency float64 // in milliseconds

TabletCacheStatus contains the status per destination for a gateway.

func (*TabletCacheStatus) FormattedQPS Uses

func (tcs *TabletCacheStatus) FormattedQPS() string

FormattedQPS shows a 2 digit rounded value of QPS. Used in the HTML template above.

type TabletCacheStatusList Uses

type TabletCacheStatusList []*TabletCacheStatus

TabletCacheStatusList is a slice of TabletCacheStatus.

func (TabletCacheStatusList) Len Uses

func (gtcsl TabletCacheStatusList) Len() int

Len is part of sort.Interface.

func (TabletCacheStatusList) Less Uses

func (gtcsl TabletCacheStatusList) Less(i, j int) bool

Less is part of sort.Interface.

func (TabletCacheStatusList) Swap Uses

func (gtcsl TabletCacheStatusList) Swap(i, j int)

Swap is part of sort.Interface.

type TabletStatusAggregator Uses

type TabletStatusAggregator struct {
    Keyspace   string
    Shard      string
    TabletType topodatapb.TabletType
    Name       string // the alternative name of a tablet
    Addr       string // the host:port of a tablet

    QueryCount uint64
    QueryError uint64
    // contains filtered or unexported fields

TabletStatusAggregator tracks tablet status for a gateway.

func NewTabletStatusAggregator Uses

func NewTabletStatusAggregator(keyspace, shard string, tabletType topodatapb.TabletType, name string) *TabletStatusAggregator

NewTabletStatusAggregator creates a TabletStatusAggregator.

func (*TabletStatusAggregator) GetCacheStatus Uses

func (tsa *TabletStatusAggregator) GetCacheStatus() *TabletCacheStatus

GetCacheStatus returns a TabletCacheStatus representing the current gateway status.

func (*TabletStatusAggregator) UpdateQueryInfo Uses

func (tsa *TabletStatusAggregator) UpdateQueryInfo(addr string, tabletType topodatapb.TabletType, elapsed time.Duration, hasError bool)

UpdateQueryInfo updates the aggregator with the given information about a query.

Package gateway imports 22 packages (graph) and is imported by 6 packages. Updated 2019-06-11. Refresh now. Tools for package owners.