luci: go.chromium.org/luci/resultdb/sink Index | Files

package sink

import "go.chromium.org/luci/resultdb/sink"

Copyright 2020 The LUCI Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Package sink provides a server for aggregating test results and sending them to the ResultDB backend.

Copyright 2020 The LUCI Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2020 The LUCI Authors.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Package Files

rdb_channel.go sink.go sink_server.go testutil.go

Constants

const (
    // DefaultAddr is the TCP address that the Server listens on by default.
    DefaultAddr = "localhost:62115"
    // AuthTokenKey is the key of the HTTP request header where the auth token should
    // be specified. Note that the an HTTP request must have the auth token in the header
    // with the following format.
    // Authorization: ResultSink <auth_token>
    AuthTokenKey = "Authorization"
    // AuthTokenPrefix is embedded into the value of the Authorization HTTP request header,
    // where the auth_token must be present. For the details about the value format of
    // the Authoization HTTP request header, find the description of `AuthTokenKey`.
    AuthTokenPrefix = "ResultSink"
)

Variables

var ErrCloseBeforeStart error = errors.Reason("the server is not started yet").Err()

ErrCloseBeforeStart is returned by Close(), when it was invoked before the server started.

type Server Uses

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

Server contains state relevant to the server itself. It should always be created by a call to NewServer. After a call to Serve(), Server will accept connections on its Port and gather test results to send to its Recorder.

func NewServer Uses

func NewServer(cfg ServerConfig) *Server

NewServer creates a Server value and populates optional values with defaults. It panics if cfg.Recorder is nil.

func (*Server) Close Uses

func (s *Server) Close() error

Close immediately stops the servers and cancels the requests that are being processed.

func (*Server) Config Uses

func (s *Server) Config() ServerConfig

Config retrieves the ServerConfig of a previously created Server.

Use this to retrieve the resolved values of unset optional fields in the original ServerConfig.

func (*Server) ErrC Uses

func (s *Server) ErrC() <-chan error

ErrC returns a channel that transmits a server error.

Receiving an error on this channel implies that the server has either stopped running or is in the process of stopping.

func (*Server) Export Uses

func (s *Server) Export(ctx context.Context) context.Context

Export exports lucictx.ResultSink derived from the server configuration into the context.

func (*Server) Run Uses

func (s *Server) Run(ctx context.Context, callback func(context.Context) error) error

Run invokes callback in a context where the server is running.

The context passed to callback will be cancelled if the server encounters an error. The context also has the server's information exported into it. If callback finishes running, Run will return the error it returned.

func (*Server) Start Uses

func (s *Server) Start(ctx context.Context) error

Start runs the server.

On success, Start will return nil, and a subsequent error will be sent on the server's ErrC channel.

type ServerConfig Uses

type ServerConfig struct {
    // Recorder is the gRPC client to the Recorder service exposed by ResultDB.
    Recorder pb.RecorderClient

    // AuthToken is a secret token to expect from clients. If it is "" then it
    // will be randomly generated in a secure way.
    AuthToken string
    // Address is the HTTP address to listen on. If empty, the server will use
    // the default address.
    Address string

    // Invocation is the name of the invocation that test results should append
    // to.
    Invocation string
    // UpdateToken is the token that allows writes to Invocation.
    UpdateToken string

    // TestIDPrefix will be prepended to the test_id of each TestResult.
    TestIDPrefix string
}

ServerConfig defines the parameters of the server.

Package sink imports 33 packages (graph) and is imported by 1 packages. Updated 2020-04-06. Refresh now. Tools for package owners.