rpc

package
v0.8.99 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	LineStdout int = iota
	LineStderr
	LineExitCode
	LineMetadata
	LineProgress
)

Identifies the type of line in the logs.

Variables

View Source
var NoFilter = Filter{}

NoFilter is an empty filter.

Functions

This section is empty.

Types

type Client

type Client struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Client represents an rpc client.

func NewClient

func NewClient(endpoint string, opts ...Option) (*Client, error)

NewClient returns a new Client.

func (*Client) Close

func (t *Client) Close() error

Close closes the client connection.

func (*Client) Done

func (t *Client) Done(c context.Context, id string, state State) error

Done signals the pipeline is complete.

func (*Client) Extend

func (t *Client) Extend(c context.Context, id string) error

Extend extends the pipeline deadline.

func (*Client) Init

func (t *Client) Init(c context.Context, id string, state State) error

Init signals the pipeline is initialized.

func (*Client) Log

func (t *Client) Log(c context.Context, id string, line *Line) error

Log writes the pipeline log entry.

func (*Client) Next

func (t *Client) Next(c context.Context, f Filter) (*Pipeline, error)

Next returns the next pipeline in the queue.

func (*Client) Update

func (t *Client) Update(c context.Context, id string, state State) error

Update updates the pipeline state.

func (*Client) Upload

func (t *Client) Upload(c context.Context, id string, file *File) error

Upload uploads the pipeline artifact.

func (*Client) Wait

func (t *Client) Wait(c context.Context, id string) error

Wait blocks until the pipeline is complete.

type File

type File struct {
	Name string            `json:"name"`
	Proc string            `json:"proc"`
	Mime string            `json:"mime"`
	Time int64             `json:"time"`
	Size int               `json:"size"`
	Data []byte            `json:"data"`
	Meta map[string]string `json:"meta"`
}

File defines a pipeline artifact.

type Filter

type Filter struct {
	Labels map[string]string `json:"labels"`
	Expr   string            `json:"expr"`
}

Filter defines filters for fetching items from the queue.

type Health

type Health interface {
	// Check returns if server is healthy or not
	Check(c context.Context) (bool, error)
}

Health defines a health-check connection.

func NewGrpcHealthClient

func NewGrpcHealthClient(conn *grpc.ClientConn) Health

NewGrpcHealthClient returns a new grpc Client.

type Line

type Line struct {
	Proc string `json:"proc,omitempty"`
	Time int64  `json:"time,omitempty"`
	Type int    `json:"type,omitempty"`
	Pos  int    `json:"pos,omityempty"`
	Out  string `json:"out,omitempty"`
}

Line is a line of console output.

func (*Line) String

func (l *Line) String() string

type LineWriter

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

LineWriter sends logs to the client.

func NewLineWriter

func NewLineWriter(peer Peer, id, name string, secret ...string) *LineWriter

NewLineWriter returns a new line reader.

func (*LineWriter) Clear

func (w *LineWriter) Clear()

Clear clears the line history

func (*LineWriter) Lines

func (w *LineWriter) Lines() []*Line

Lines returns the line history

func (*LineWriter) Write

func (w *LineWriter) Write(p []byte) (n int, err error)

type Option

type Option func(*Client)

Option configures a client option.

func WithBackoff

func WithBackoff(d time.Duration) Option

WithBackoff configures the backoff duration when attempting to re-connect to a server.

func WithHeader

func WithHeader(key, value string) Option

WithHeader configures the client header.

func WithRetryLimit

func WithRetryLimit(i int) Option

WithRetryLimit configures the maximum number of retries when connecting to the server.

func WithToken

func WithToken(t string) Option

WithToken configures the client authorization token.

type Peer

type Peer interface {
	// Next returns the next pipeline in the queue.
	Next(c context.Context, f Filter) (*Pipeline, error)

	// Wait blocks until the pipeline is complete.
	Wait(c context.Context, id string) error

	// Init signals the pipeline is initialized.
	Init(c context.Context, id string, state State) error

	// Done signals the pipeline is complete.
	Done(c context.Context, id string, state State) error

	// Extend extends the pipeline deadline
	Extend(c context.Context, id string) error

	// Update updates the pipeline state.
	Update(c context.Context, id string, state State) error

	// Upload uploads the pipeline artifact.
	Upload(c context.Context, id string, file *File) error

	// Log writes the pipeline log entry.
	Log(c context.Context, id string, line *Line) error
}

Peer defines a peer-to-peer connection.

func NewGrpcClient

func NewGrpcClient(conn *grpc.ClientConn) Peer

NewGrpcClient returns a new grpc Client.

type Pipeline

type Pipeline struct {
	ID      string          `json:"id"`
	Config  *backend.Config `json:"config"`
	Timeout int64           `json:"timeout"`
}

Pipeline defines the pipeline execution details.

type Server

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

Server represents an rpc server.

func NewServer

func NewServer(peer Peer) *Server

NewServer returns an rpc Server.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements an http.Handler that answers rpc requests.

type State

type State struct {
	Proc     string `json:"proc"`
	Exited   bool   `json:"exited"`
	ExitCode int    `json:"exit_code"`
	Started  int64  `json:"started"`
	Finished int64  `json:"finished"`
	Error    string `json:"error"`
}

State defines the pipeline state.

Directories

Path Synopsis
Package proto is a generated protocol buffer package.
Package proto is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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