gw

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: Apache-2.0 Imports: 40 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyNotFound   = status.Error(codes.Unknown, "key not found")
	ErrCorruptedData = status.Error(codes.Aborted, "data is corrupted") // codes.Aborted is translated in StatusConflict 409 http error
)

sdk errors

View Source
var (
	ErrIllegalArgument   = errors.New("illegal arguments: empty key")
	ErrKeyNotFoundTBTree = errors.New("tbtree: key not found")
)

wrap server errors which are not constants in immudb

View Source
var (
	StatusErrKeyNotFound   = status.Error(codes.NotFound, "")
	StatusDatabaseNotFound = status.Error(codes.NotFound, "")
)
View Source
var (
	ErrInvalidItemProof = errors.New("proof does not match the given item")
)

ErrInvalidItemProof ...

Functions

func RegisterImmuServiceHandlerClient added in v1.3.0

func RegisterImmuServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, gwclient immugwclient.Client, defaultClient schema.ImmuServiceClient) error

RegisterImmuServiceHandlerClient registers the http handlers for service ImmuService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "immugwclient.Client". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "immugwclient.Client" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "immugwclient.Client" to call the correct interceptors.

Types

type HistoryHandler

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

HistoryHandler ...

func NewHistoryHandler

func NewHistoryHandler(mux *runtime.ServeMux, client immugwclient.Client, rt Runtime, json json.JSON) HistoryHandler

NewHistoryHandler ...

type ImmuGw

type ImmuGw interface {
	Start() error
	Stop() error
	WithClient(schema.ImmuServiceClient) ImmuGw
	WithLogger(logger.Logger) ImmuGw
	WithOptions(Options) ImmuGw
	WithCliOptions(client.Options) ImmuGw
}

ImmuGw ...

type ImmuGwServer

type ImmuGwServer struct {
	Options    Options
	CliOptions client.Options

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

ImmuGwServer ...

func DefaultServer

func DefaultServer() *ImmuGwServer

DefaultServer returns a default immudb gateway server

func (*ImmuGwServer) Start

func (s *ImmuGwServer) Start() error

Start starts the immudb gateway server

func (*ImmuGwServer) Stop

func (s *ImmuGwServer) Stop() error

Stop stops the immudb gateway server

func (*ImmuGwServer) WithCliOptions

func (c *ImmuGwServer) WithCliOptions(cliOptions client.Options) ImmuGw

WithCliOptions ...

func (*ImmuGwServer) WithClient

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

WithClient ...

func (*ImmuGwServer) WithLogger

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

WithLogger ...

func (*ImmuGwServer) WithOptions

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

WithOptions ...

type ImmuGwServerMock

type ImmuGwServerMock struct {
	StartF          func() error
	StopF           func() error
	WithClientF     func(schema.ImmuServiceClient) ImmuGw
	WithLoggerF     func(logger.Logger) ImmuGw
	WithOptionsF    func(Options) ImmuGw
	WithCliOptionsF func(client.Options) ImmuGw
}

ImmuGwServerMock ...

func (*ImmuGwServerMock) Start

func (igm *ImmuGwServerMock) Start() error

Start ...

func (*ImmuGwServerMock) Stop

func (igm *ImmuGwServerMock) Stop() error

Stop ...

func (*ImmuGwServerMock) WithCliOptions

func (igm *ImmuGwServerMock) WithCliOptions(options client.Options) ImmuGw

WithCliOptions ...

func (*ImmuGwServerMock) WithClient

func (igm *ImmuGwServerMock) WithClient(client schema.ImmuServiceClient) ImmuGw

WithClient ...

func (*ImmuGwServerMock) WithLogger

func (igm *ImmuGwServerMock) WithLogger(logger logger.Logger) ImmuGw

WithLogger ...

func (*ImmuGwServerMock) WithOptions

func (igm *ImmuGwServerMock) WithOptions(options Options) ImmuGw

WithOptions ...

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
}

LastAuditResult ...

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
}

MetricsCollection the gateway metrics collection

func (MetricsCollection) UpdateAuditResult

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

UpdateAuditResult updates the metrics related to audit result

func (MetricsCollection) WithUptimeCounter

func (mc MetricsCollection) WithUptimeCounter(reg *prometheus.Registry, f func() float64)

WithUptimeCounter ...

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 `json:"-"`
	AuditSignature string
	Detached       bool
	MTLs           bool
	MTLsOptions    client.MTLsOptions
	Config         string
	Pidfile        string
	Logfile        string
	TokenService   tokenservice.TokenService
}

Options immudb gateway server options

func DefaultOptions

func DefaultOptions() Options

DefaultOptions ...

func (Options) Bind

func (o Options) Bind() string

Bind concatenates address and port

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) WithAuditSignature

func (o Options) WithAuditSignature(auditSignature string) Options

WithAuditSignature sets AuditSignature

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

func (Options) WithTokenService added in v1.2.0

func (o Options) WithTokenService(tokenService tokenservice.TokenService) Options

type Runtime

Runtime ...

func DefaultRuntime

func DefaultRuntime() Runtime

DefaultRuntime ...

type SafeReferenceHandler

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

SafeReferenceHandler ...

func NewSafeReferenceHandler

func NewSafeReferenceHandler(mux *runtime.ServeMux, client immugwclient.Client, rt Runtime, json json.JSON) SafeReferenceHandler

NewSafeReferenceHandler ...

type Service

type Service struct {
	ImmuGwServer ImmuGw
}

Service ...

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)
}

SetHandler ...

func NewSetHandler

func NewSetHandler(mux *runtime.ServeMux, client immugwclient.Client, rt Runtime, json json.JSON) SetHandler

NewSetHandler ...

type UseDatabaseHandler

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

UseDatabaseHandler ...

func NewUseDatabaseHandler

func NewUseDatabaseHandler(mux *runtime.ServeMux, client immugwclient.Client, rt Runtime, json json.JSON) UseDatabaseHandler

NewUseDatabaseHandler ...

type VerifiedGetHandler added in v1.0.5

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

VerifiedGetHandler ...

func NewVerifiedGetHandler added in v1.0.5

func NewVerifiedGetHandler(mux *runtime.ServeMux, client immugwclient.Client, rt Runtime, json json.JSON) VerifiedGetHandler

NewVerifiedGetHandler ...

type VerifiedSQLGetHandler added in v1.1.0

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

VerifiedGetHandler ...

func NewVerifiedSQLGetHandler added in v1.1.0

func NewVerifiedSQLGetHandler(mux *runtime.ServeMux, client immugwclient.Client, rt Runtime, json json.JSON) VerifiedSQLGetHandler

NewVerifiedSQLGetHandler ...

type VerifiedSetHandler added in v1.0.5

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

VerifiedSetHandler ...

func NewVerifiedSetHandler added in v1.0.5

func NewVerifiedSetHandler(mux *runtime.ServeMux, client immugwclient.Client, rt Runtime, json json.JSON) VerifiedSetHandler

NewVerifiedSetHandler ...

type VerifiedTxByIdHandler added in v1.0.5

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

VerifiedTxByIdHandler ...

func NewVerifiedTxByIdHandler added in v1.0.5

func NewVerifiedTxByIdHandler(mux *runtime.ServeMux, client immugwclient.Client, rt Runtime, json json.JSON) VerifiedTxByIdHandler

NewVerifiedTxById ...

type VerifiedZaddHandler added in v1.0.5

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

VerifiedZaddHandler ...

func NewVerifiedZaddHandler added in v1.0.5

func NewVerifiedZaddHandler(mux *runtime.ServeMux, client immugwclient.Client, rt Runtime, json json.JSON) VerifiedZaddHandler

NewVerifiedZaddHandler ...

Jump to

Keyboard shortcuts

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