gw

package
v0.6.1 Latest Latest
Warning

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

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

Documentation

Overview

Copyright 2019-2020 vChain, Inc.

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 2019-2020 vChain, Inc.

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

Constants

This section is empty.

Variables

View Source
var (
	InvalidItemProof = errors.New("proof does not match the given item")
)
View Source
var Metrics = MetricsCollection{

	AuditResultPerServer: newAuditGaugeVec(
		"audit_result_per_server",
		"Latest audit result (1 = ok, 0 = tampered).",
	),
	AuditPrevRootPerServer: newAuditGaugeVec(
		"audit_prev_root_per_server",
		"Previous root index used for the latest audit.",
	),
	AuditCurrRootPerServer: newAuditGaugeVec(
		"audit_curr_root_per_server",
		"Current root index used for the latest audit.",
	),
	AuditRunAtPerServer: newAuditGaugeVec(
		"audit_run_at_per_server",
		"Timestamp in unix seconds at which latest audit run.",
	),
	// contains filtered or unexported fields
}

Functions

func StartMetrics

func StartMetrics(
	addr string,
	l logger.Logger,
	uptimeCounter func() float64,
) *http.Server

StartMetrics listens and servers the HTTP metrics server in a new goroutine. The server is then returned and can be stopped using Close().

Types

type HistoryHandler

type HistoryHandler interface {
	History(w http.ResponseWriter, req *http.Request, pathParams map[string]string)
}

func NewHistoryHandler

func NewHistoryHandler(mux *runtime.ServeMux, client client.ImmuClient) HistoryHandler

type ImmuGwServer

type ImmuGwServer struct {
	Options Options

	Logger logger.Logger
	Pid    server.PIDFile
	Client schema.ImmuServiceClient
	// contains filtered or unexported fields
}

func DefaultServer

func DefaultServer() *ImmuGwServer

func (*ImmuGwServer) Start

func (s *ImmuGwServer) Start() error

func (*ImmuGwServer) Stop

func (s *ImmuGwServer) Stop() error

func (*ImmuGwServer) WithClient

func (c *ImmuGwServer) WithClient(client schema.ImmuServiceClient) *ImmuGwServer

func (*ImmuGwServer) WithLogger

func (c *ImmuGwServer) WithLogger(logger logger.Logger) *ImmuGwServer

func (*ImmuGwServer) WithOptions

func (c *ImmuGwServer) WithOptions(options Options) *ImmuGwServer

type LastAuditResult

type LastAuditResult struct {
	ServerID               string
	ServerAddress          string
	HasRunConsistencyCheck bool
	HasError               bool
	ConsistencyCheckResult bool
	PreviousRootIndex      float64
	PreviousRoot           string
	CurrentRootIndex       float64
	CurrentRoot            string
	RunAt                  time.Time
	sync.RWMutex
}

type MetricsCollection

type MetricsCollection struct {
	AuditResultPerServer   *prometheus.GaugeVec
	AuditPrevRootPerServer *prometheus.GaugeVec
	AuditCurrRootPerServer *prometheus.GaugeVec
	AuditRunAtPerServer    *prometheus.GaugeVec

	UptimeCounter prometheus.CounterFunc
	// contains filtered or unexported fields
}

func (*MetricsCollection) UpdateAuditResult

func (mc *MetricsCollection) UpdateAuditResult(
	serverID string,
	serverAddress string,
	checked bool,
	withError bool,
	result bool,
	prevRoot *schema.Root,
	currRoot *schema.Root,
)

func (*MetricsCollection) WithUptimeCounter

func (mc *MetricsCollection) WithUptimeCounter(f func() float64)

type Options

type Options struct {
	Dir           string
	Address       string
	Port          int
	MetricsPort   int
	ImmudbAddress string
	ImmudbPort    int
	Audit         bool
	AuditInterval time.Duration
	AuditUsername string
	AuditPassword string
	Detached      bool
	MTLs          bool
	MTLsOptions   client.MTLsOptions
	Config        string
	Pidfile       string
	Logfile       string
}

func DefaultOptions

func DefaultOptions() Options

func (Options) Bind

func (o Options) Bind() string

func (Options) MetricsBind

func (o Options) MetricsBind() string

MetricsBind return metrics bind address

func (Options) String

func (o Options) String() string

func (Options) WithAddress

func (o Options) WithAddress(address string) Options

WithAddress sets address

func (Options) WithAudit

func (o Options) WithAudit(audit bool) Options

WithAudit sets Audit

func (Options) WithAuditInterval

func (o Options) WithAuditInterval(auditInterval time.Duration) Options

WithAuditInterval sets AuditInterval

func (Options) WithAuditPassword

func (o Options) WithAuditPassword(auditPassword string) Options

WithAuditPassword sets AuditPassword

func (Options) WithAuditUsername

func (o Options) WithAuditUsername(auditUsername string) Options

WithAuditUsername sets AuditUsername

func (Options) WithConfig

func (o Options) WithConfig(config string) Options

WithConfig sets config

func (Options) WithDetached

func (o Options) WithDetached(detached bool) Options

WithDetached sets immugw to be run in background

func (Options) WithDir

func (o Options) WithDir(dir string) Options

WithDir sets dir

func (Options) WithImmudbAddress

func (o Options) WithImmudbAddress(immudbAddress string) Options

WithImmudbAddress sets immudbAddress

func (Options) WithImmudbPort

func (o Options) WithImmudbPort(immudbPort int) Options

WithImmudbPort sets immudbPort

func (Options) WithLogfile

func (o Options) WithLogfile(logfile string) Options

WithLogfile sets logfile

func (Options) WithMTLs

func (o Options) WithMTLs(MTLs bool) Options

WithMTLs sets MTLs

func (Options) WithMTLsOptions

func (o Options) WithMTLsOptions(MTLsOptions client.MTLsOptions) Options

WithMTLsOptions sets MTLsOptions

func (Options) WithPidfile

func (o Options) WithPidfile(pidfile string) Options

WithPidfile sets pidfile

func (Options) WithPort

func (o Options) WithPort(port int) Options

WithPort sets port

type SafeReferenceHandler

type SafeReferenceHandler interface {
	SafeReference(w http.ResponseWriter, req *http.Request, pathParams map[string]string)
}

func NewSafeReferenceHandler

func NewSafeReferenceHandler(mux *runtime.ServeMux, client client.ImmuClient) SafeReferenceHandler

type SafeZAddHandler

type SafeZAddHandler interface {
	SafeZAdd(w http.ResponseWriter, req *http.Request, pathParams map[string]string)
}

func NewSafeZAddHandler

func NewSafeZAddHandler(mux *runtime.ServeMux, client client.ImmuClient) SafeZAddHandler

type SafegetHandler

type SafegetHandler interface {
	Safeget(w http.ResponseWriter, req *http.Request, pathParams map[string]string)
}

func NewSafegetHandler

func NewSafegetHandler(mux *runtime.ServeMux, client client.ImmuClient) SafegetHandler

type SafesetHandler

type SafesetHandler interface {
	Safeset(w http.ResponseWriter, req *http.Request, pathParams map[string]string)
}

func NewSafesetHandler

func NewSafesetHandler(mux *runtime.ServeMux, client client.ImmuClient) SafesetHandler

type Service

type Service struct {
	ImmuGwServer
}

func (Service) Run

func (s Service) Run()

Run - blocking run service

func (Service) Start

func (s Service) Start()

Start - non-blocking start service

func (Service) Stop

func (s Service) Stop()

Stop - non-blocking stop service

type SetHandler

type SetHandler interface {
	Set(w http.ResponseWriter, req *http.Request, pathParams map[string]string)
}

func NewSetHandler

func NewSetHandler(mux *runtime.ServeMux, client client.ImmuClient) SetHandler

Jump to

Keyboard shortcuts

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