Documentation ¶
Index ¶
- Constants
- Variables
- func DecryptTicketL2(ctx context.Context, secret, ciphertext []byte) (*ccmsg.TicketL2, error)
- func EncryptTicketL2(p *colocationpuzzle.Puzzle, t *ccmsg.TicketL2) ([]byte, error)
- func ErrorResponse(w http.ResponseWriter, err error)
- func GRPCDial(target string, insecure bool, opts ...grpc.DialOption) (*grpc.ClientConn, error)
- func IsErrConnRefused(err error) bool
- func IsNetErrClosing(err error) bool
- func IsWebSocketClose(err error, statusCodes ...int) bool
- func JSONResponse(w http.ResponseWriter, respObj interface{})
- func JSONResponseC(w http.ResponseWriter, respObj interface{}) error
- func Main(mainC func() error)
- func NewDBGRPCServer(db *sql.DB, opt ...grpc.ServerOption) *grpc.Server
- func NewGRPCServer(opt ...grpc.ServerOption) *grpc.Server
- func RunStarterShutdowner(l *logrus.Logger, o StarterShutdowner) error
- type ChunkID
- type ConfigParser
- func (p *ConfigParser) GetBool(key string, fallback bool) bool
- func (p *ConfigParser) GetInsecure() bool
- func (p *ConfigParser) GetInt64(key string, fallback int64) int64
- func (p *ConfigParser) GetSeconds(key string, fallback int64) time.Duration
- func (p *ConfigParser) GetString(key string, fallback string) string
- func (p *ConfigParser) ReadFile(path string) error
- type EscrowID
- func (id EscrowID) MarshalText() ([]byte, error)
- func (id *EscrowID) Randomize(nextInt func() int64, fieldType string, shouldBeNull bool)
- func (id *EscrowID) Scan(src interface{}) error
- func (id EscrowID) String() string
- func (id EscrowID) UnmarshalText(x []byte) error
- func (id EscrowID) Value() (driver.Value, error)
- type Flushable
- type MetricsPusher
- type MyHandlerFunc
- type ObjectID
- type StarterShutdowner
- type WebError
Constants ¶
const ( EscrowIDSize = 16 ObjectIDSize = 16 ChunkIDSize = 16 )
Variables ¶
var (
ErrMethodNotAllowed = &webError{status: http.StatusMethodNotAllowed}
)
Functions ¶
func DecryptTicketL2 ¶
func EncryptTicketL2 ¶
func ErrorResponse ¶
func ErrorResponse(w http.ResponseWriter, err error)
func GRPCDial ¶
func GRPCDial(target string, insecure bool, opts ...grpc.DialOption) (*grpc.ClientConn, error)
GRPCDial creates a client connection to the given target.
func IsErrConnRefused ¶
IsErrConnRefused returns true iff the error is a network error corresponding to ECONNREFUSED being returned from a syscall like listen(2).
func IsNetErrClosing ¶
IsNetErrClosing returns true iff err is net.errClosing: "use of closed network connection". This helper exists because that error is not exported.
func IsWebSocketClose ¶
IsWebSocketClose returns true iff err is indicates that a WebSocket connection has been closed with one of the indicated status codes.
func JSONResponse ¶
func JSONResponse(w http.ResponseWriter, respObj interface{})
func JSONResponseC ¶
func JSONResponseC(w http.ResponseWriter, respObj interface{}) error
func Main ¶
func Main(mainC func() error)
Main provides a convenient thunk to allow writing a CLI with more idiomatic go - returning error rather than calling os.Exit. A small thunk is still needed. If mainC returns non-nil the error reported to stderr and a non-zero exit code is reported to the OS.
```
func main() { common.Main(mainC) }
```
func NewDBGRPCServer ¶
New GRPCServer makes a DB enabled GRPC server preconfigured with tracing and monitoring middleware.
func NewGRPCServer ¶
func NewGRPCServer(opt ...grpc.ServerOption) *grpc.Server
NewGRPCServer makes a stateless GRPC server preconfigured with tracing and monitoring middleware.
func RunStarterShutdowner ¶
func RunStarterShutdowner(l *logrus.Logger, o StarterShutdowner) error
Types ¶
type ChunkID ¶
type ChunkID [ChunkIDSize]byte
func BytesToChunkID ¶
type ConfigParser ¶
type ConfigParser struct {
// contains filtered or unexported fields
}
func NewConfigParser ¶
func NewConfigParser(l *logrus.Logger, prefix string) (*ConfigParser, error)
func (*ConfigParser) GetInsecure ¶
func (p *ConfigParser) GetInsecure() bool
GetInsecure returns the well known insecure setting, logging it for diagnostics. Insecure disables TLS checking on bootstrap/publisher/observability endpoints.
func (*ConfigParser) GetSeconds ¶
func (p *ConfigParser) GetSeconds(key string, fallback int64) time.Duration
func (*ConfigParser) GetString ¶
func (p *ConfigParser) GetString(key string, fallback string) string
func (*ConfigParser) ReadFile ¶
func (p *ConfigParser) ReadFile(path string) error
type EscrowID ¶
type EscrowID [EscrowIDSize]byte
func BytesToEscrowID ¶
func (EscrowID) MarshalText ¶
These are here to support marshaling as JSON map keys.
func (*EscrowID) Randomize ¶
TODO: I don't think that we need to support `fieldType` here, but do we need to support `shouldBeNull`? Their purpose is explained in the Randomizer docs.
func (EscrowID) UnmarshalText ¶
type Flushable ¶
type Flushable struct {
// contains filtered or unexported fields
}
Flushable is a wrapper for jaeger.Exporter to permit clean code in callers while permitting tracing to be disabled.
func SetupTracing ¶
SetupTracing configures OpenCensus to export to Jaeger.
type MetricsPusher ¶
type MetricsPusher struct {
// contains filtered or unexported fields
}
MetricsPusher sends metrics to the CacheCash central metrics store
func NewMetricsPusher ¶
func NewMetricsPusher(l *logrus.Logger, endpoint string, insecure bool, kp *keypair.KeyPair) *MetricsPusher
NewMetricsPusher creates a new MetricsPusher
type MyHandlerFunc ¶
type MyHandlerFunc func(w http.ResponseWriter, req *http.Request) (respObj interface{}, err WebError)
type ObjectID ¶
type ObjectID [ObjectIDSize]byte
func BytesToObjectID ¶
type StarterShutdowner ¶
type StarterShutdowner interface { // Start kicks off any internal goroutines that are necessary and returns synchronously. It may temporarily block // until whatever needs to be started has been started. Start() error // Shutdown blocks until a graceful shutdown takes place. If the provided context expires, the shutdown is forced. Shutdown(context.Context) error }