viewclient

package
v0.0.0-...-6719cd2 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package viewclient provides functionality for querying view servers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CarouselClient

type CarouselClient struct {
	View viewreg.View
	Stub rpc.CarouselClient
}

CarouselClient is a client for the Carousel service running on the particular view instance

func (*CarouselClient) Serves

func (c *CarouselClient) Serves() space.Range

Serves returns the Range in the HashSpace that this view contains.

func (*CarouselClient) String

func (c *CarouselClient) String() string

type CarouselClients

type CarouselClients []*CarouselClient

CarouselClients is a collection of CarouselClient, you typically get one of these from the Client.CarouselViews() method.

func (CarouselClients) Len

func (c CarouselClients) Len() int

Len returns the number of clients in this list. This is part of the implementation of the fanout.Views interface

func (CarouselClients) View

func (c CarouselClients) View(i int) fanout.View

View returns the i'th client in this collect. This is part of the implementation of the fanout.Views interface

type CarouselConsumer

type CarouselConsumer interface {
	ReplayPosition() rpc.LogPosition
	DataCh() <-chan *rpc.CarouselResult
	ErrorsCh() <-chan error
	Stop()
}

CarouselConsumer provides ways for a client of a carousel request to consume the resulting data

type Client

type Client struct {
	Registry *viewreg.Registry
	// contains filtered or unexported fields
}

Client is a compatibility layer around the newer viewreg.Registry. Client currently owns its Registry, but in the future we plan for the current users of Client to manage their own Registry.

TODO: meh viewclient.Client

func New

func New(cfg *config.Akutan) (*Client, error)

New constructs a Client that uses view instances from the given configuration.

func NewWithLocator

func NewWithLocator(cfg *config.Akutan, views discovery.Locator) *Client

NewWithLocator constructs a Client that finds view instances from the given Locator.

func (*Client) CarouselViews

func (c *Client) CarouselViews(pred ViewInfoPredicate) CarouselClients

CarouselViews returns all views that support the Carousel feature, if pred is non-nil only those views passing the view predicate are included

func (*Client) Close

func (c *Client) Close()

Close shuts down the view registry, disconnecting from all the views. After this, the Client is no longer useful, as it will not initiate new connections. Close() is safe to call more than once.

func (*Client) DiagnosticsViews

func (c *Client) DiagnosticsViews() []*DiagnosticsClient

DiagnosticsViews returns all views that support the Diagnostics feature.

func (*Client) FactStats

func (c *Client) FactStats(ctx context.Context, overallReq *rpc.FactStatsRequest) (*FactStats, error)

FactStats collects data about the distributions of facts in the store. It fans out to many view servers, which have this data readily available, and collects it all together.

func (*Client) LogStatus

func (c *Client) LogStatus(ctx context.Context, clients CarouselClients) (*LogStatusResult, error)

LogStatus will call LogStatus on each of the supplied client views, and aggregate the results into an all clients wide view. For each normalized partition it collects the most recent atIndex and the oldest replay index then takes the overall min of each for an overall view.

func (*Client) LookupPO

func (c *Client) LookupPO(ctx context.Context, req *rpcdef.LookupPORequest, resCh chan *rpcdef.LookupChunk) error

LookupPO calls out to views and collects all facts that match the given predicate-objects. LookupPO produces facts in an undefined order, but it guarantees the facts are distinct (it filters duplicate facts caused by RPC hedging and errors). The returned facts have their fields fully populated. See StreamingConvention for how to call LookupPO.

func (*Client) LookupPOCmp

func (c *Client) LookupPOCmp(ctx context.Context, req *rpcdef.LookupPOCmpRequest, resCh chan *rpcdef.LookupChunk) error

LookupPOCmp calls out to views and collects all facts that match the given predicate and the given object criteria. LookupPOCmp produces facts in an undefined order, but it guarantees the facts are distinct (it filters duplicate facts caused by RPC hedging and errors). The returned facts have their fields fully populated. See StreamingConvention for how to call LookupPOcmp.

func (*Client) LookupS

func (c *Client) LookupS(ctx context.Context, req *rpcdef.LookupSRequest, resCh chan *rpcdef.LookupChunk) error

LookupS calls out to views and collects all facts that match the given subjects. LookupS produces facts in an undefined order, but it guarantees the facts are distinct (it filters duplicate facts caused by RPC hedging and errors). The returned facts have their fields fully populated. See StreamingConvention for how to call LookupS.

func (*Client) LookupSP

func (c *Client) LookupSP(ctx context.Context, req *rpcdef.LookupSPRequest, resCh chan *rpcdef.LookupChunk) error

LookupSP calls out to views and collects all facts that match the given subject-predicates. LookupSP produces facts in an undefined order, but it guarantees the facts are distinct (it filters duplicate facts caused byRPC hedging and errors). The returned facts have their fields fully populated. See StreamingConvention for how to call LookupSP.

func (*Client) LookupSPO

func (c *Client) LookupSPO(ctx context.Context, req *rpcdef.LookupSPORequest, resCh chan *rpcdef.LookupChunk) error

LookupSPO calls out to views and collects all facts that match the given subject-predicate-objects. LookupSPO produces facts in an undefined order, but it guarantees the facts are distinct (it filters duplicate facts caused by RPC hedging and errors). The returned facts have their fields fully populated. See StreamingConvention for how to call LookupSP.

func (*Client) ReadFactsPOViews

func (c *Client) ReadFactsPOViews() ReadFactsPOClients

ReadFactsPOViews returns all views that support the ReadFactsPO feature.

func (*Client) ReadFactsSPViews

func (c *Client) ReadFactsSPViews() ReadFactsSPClients

ReadFactsSPViews returns all views that support the ReadFactsSP feature.

func (*Client) RideCarousel

func (c *Client) RideCarousel(ctx context.Context, req *rpc.CarouselRequest, viewPred ViewInfoPredicate) (CarouselConsumer, error)

RideCarousel will start a carousel client, fanning out the carousel request to the relevant source views. This will check with the views to find the most recent index where there are no pending transactions and start the carousel from that.

if viewPred is not empty, then only views that pass this predicate will be included. For efficiency this will try to select views that use the same key encoding as the request, as that can reduce the number of views needed to fetch data from (because we can safely rule out that some view won't have any relevant data). However if needed it will fallback to Carouselling across the entire key space of an alternative key encoding.

func (*Client) Stats

func (c *Client) Stats(ctx context.Context) []ViewStats

Stats makes a best effort attempt to collect general service statistics from all views that expose them. For each view consulted there will be an entry in the returned slice.

func (*Client) UpdateStats

func (c *Client) UpdateStats(ctx context.Context) error

UpdateStats asks all the views to start recalculating their fact statistics if an error is encountered from one or more the views, it is returned, however that does not stop this trying to trigger the update on the remaining views.

type DiagnosticsClient

type DiagnosticsClient struct {
	View viewreg.View
	Stub rpc.DiagnosticsClient
}

DiagnosticsClient is a client for the Diagnostic service running on the particular view instance

func (*DiagnosticsClient) String

func (c *DiagnosticsClient) String() string

type FactStats

type FactStats struct {
	// contains filtered or unexported fields
}

FactStats contains statistics about how facts are distributed in the overall database.

func (*FactStats) BytesPerFact

func (stats *FactStats) BytesPerFact() int

BytesPerFact Implements planner.Stats.BytesPerFact().

func (*FactStats) NumFacts

func (stats *FactStats) NumFacts() int

NumFacts Implements planner.Stats.NumFacts().

func (*FactStats) NumFactsO

func (stats *FactStats) NumFactsO(object rpc.KGObject) int

NumFactsO Implements planner.Stats.NumFactsO().

func (*FactStats) NumFactsP

func (stats *FactStats) NumFactsP(predicate uint64) int

NumFactsP Implements planner.Stats.NumFactsP().

func (*FactStats) NumFactsPO

func (stats *FactStats) NumFactsPO(predicate uint64, object rpc.KGObject) int

NumFactsPO Implements planner.Stats.NumFactsPO().

func (*FactStats) NumFactsS

func (stats *FactStats) NumFactsS(subject uint64) int

NumFactsS Implements planner.Stats.NumFactsS().

func (*FactStats) NumFactsSO

func (stats *FactStats) NumFactsSO(subject uint64, object rpc.KGObject) int

NumFactsSO Implements planner.Stats.NumFactsSO().

func (*FactStats) NumFactsSP

func (stats *FactStats) NumFactsSP(subject uint64, predicate uint64) int

NumFactsSP Implements planner.Stats.NumFactsSP().

func (*FactStats) ToRPCFactStats

func (stats *FactStats) ToRPCFactStats() *rpc.FactStatsResult

ToRPCFactStats will generate an rpc fact stats result from FactStats.

type LogStatusResult

type LogStatusResult struct {
	// contains filtered or unexported fields
}

LogStatusResult contains the calculated aggregate result of calling LogStatus on a set of views

func (*LogStatusResult) LastApplied

func (r *LogStatusResult) LastApplied() (blog.Index, error)

LastApplied will return the log index that all views have applied across the space range of all the encodings. If there are points not covered, it'll return an error.

func (*LogStatusResult) NextPositionInSpace

func (r *LogStatusResult) NextPositionInSpace(enc rpc.FactKeyEncoding, covering space.Range) (rpc.LogPosition, error)

NextPositionInSpace will take the highest next position from all the views covering a partition, and then return the smallest of those across all the partition that cover the 'covering' range. At least one view in every relevant partition is at the returned index. If there are points in the requested range that have no coverage an error is returned.

func (*LogStatusResult) ReplayPosition

func (r *LogStatusResult) ReplayPosition() (rpc.LogPosition, error)

ReplayPosition will return the oldest replay position across the full space range of all the encodings. If there are points that don't have any results it'll return an error.

func (*LogStatusResult) ReplayPositionInSpace

func (r *LogStatusResult) ReplayPositionInSpace(enc rpc.FactKeyEncoding, covering space.Range) (rpc.LogPosition, error)

ReplayPositionInSpace will return the recommended replay position for the indicated range of the encoding space. If a point in this requested space does not have any valid results for it it'll return an error. If there are enough views (more than 2) for a partition, it'll ignore the worst value for that partition so that significant laggards or new views still catching up don't force processing of a lot of log. e.g. for the carousel its worth skipping the trailing view so that we can carousel at a more recent index requiring less catchup work once the carousel completes

func (*LogStatusResult) Results

func (r *LogStatusResult) Results() ([]*rpc.LogStatusResult, []error)

Results returns the underlying LogStatusResult and error for all the requested views

type ReadFactsPOClient

type ReadFactsPOClient struct {
	View viewreg.View
	Stub rpc.ReadFactsPOClient
}

ReadFactsPOClient is a client for the ReadFactsPO service running on the particular view instance

func (*ReadFactsPOClient) Serves

func (c *ReadFactsPOClient) Serves() space.Range

Serves returns the hash range that this view contains. this is an implementation of the fanout.View interface

func (*ReadFactsPOClient) String

func (c *ReadFactsPOClient) String() string

type ReadFactsPOClients

type ReadFactsPOClients []*ReadFactsPOClient

ReadFactsPOClients is a collection of ReadFatsPOClient's. Typically you'd get these from a call to Client.ReadFactsPOViews()

func (ReadFactsPOClients) Len

func (c ReadFactsPOClients) Len() int

Len returns the number of clients in this collection. This is part of the implementation of the fanout.Views interface

func (ReadFactsPOClients) View

func (c ReadFactsPOClients) View(i int) fanout.View

View return's the i'th View in this collection. This is part of the implementation of the fanout.Views interface

type ReadFactsSPClient

type ReadFactsSPClient struct {
	View viewreg.View
	Stub rpc.ReadFactsSPClient
}

ReadFactsSPClient is a client for the ReadFactsSP service running on the particular view instance

func (*ReadFactsSPClient) Serves

func (c *ReadFactsSPClient) Serves() space.Range

Serves returns the range in Hash(SP) space that the related view contains. This is an implementation of the fanout.View interface

func (*ReadFactsSPClient) String

func (c *ReadFactsSPClient) String() string

type ReadFactsSPClients

type ReadFactsSPClients []*ReadFactsSPClient

ReadFactsSPClients is a collection of ReadFactsSPClient's. You typically get one of these from calling Client.ReadFactsSPViews()

func (ReadFactsSPClients) Len

func (c ReadFactsSPClients) Len() int

Len returns the number of clients in this collection. This is part of the implementation of the fanout.Views interface

func (ReadFactsSPClients) View

func (c ReadFactsSPClients) View(i int) fanout.View

View returns the i'th client in the collection. This is part of the fanout.Views interface implementation

type StreamingConvention

type StreamingConvention func(ctx context.Context, req interface{}, resCh chan interface{}) error

StreamingConvention documents the calling convention for streaming RPC results. It's not a type used in the code: this exists only for documentation.

The function will send incremental results on resCh until either: it completes successfully and returns nil, or it encounters an error and returns the error. Note that the function may complete successfully without sending any results on resCh. Whether it completes successfully or returns an error, the function closes resCh before returning.

type ViewInfoPredicate

type ViewInfoPredicate func(v viewreg.View) bool

A ViewInfoPredicate is used to filter views. Sometimes nil is used in place of a predicate that always returns true.

type ViewStats

type ViewStats struct {
	View  viewreg.View
	Err   error
	Stats *rpc.StatsResult
}

ViewStats contains statistics about the facts in a particular view

Directories

Path Synopsis
Package fanout is useful for invoking RPCs across a bunch of servers.
Package fanout is useful for invoking RPCs across a bunch of servers.
Package lookups defines go interfaces that the various LookupXX rpc wrappers expose, this can be useful in decoupling the actual Loopup implementation from its usage, allowing for easier testing
Package lookups defines go interfaces that the various LookupXX rpc wrappers expose, this can be useful in decoupling the actual Loopup implementation from its usage, allowing for easier testing
mocklookups
Package mocklookups provides a mock implementation of the various Fact lookup RPCs.
Package mocklookups provides a mock implementation of the various Fact lookup RPCs.
Package mockstore provides various mocks that store facts and can execute lookups against them.
Package mockstore provides various mocks that store facts and can execute lookups against them.
Package viewreg tracks all the known view servers in the cluster.
Package viewreg tracks all the known view servers in the cluster.

Jump to

Keyboard shortcuts

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