server

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaskString         = "******"
	DefaultPort        = 80
	DefaultAuthKeyType = "RSA"
	DefaultMode        = "KCP"
)

Variables

View Source
var (
	ErrBackendTypeNotSpecified     = errors.New("--default-backend-type must be specified")
	ErrBackendNameNotSpecified     = errors.New("--default-backend-name must be specified")
	ErrBackendEndpointNotSpecified = errors.New("--default-backend-endpoint must be specified")
	ErrBackendAKSKNotSpecified     = errors.New("no AK/SK found. Please set OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables")
)
View Source
var (
	ErrDBHostNotSpecified = errors.New("--db-host must be specified")
	ErrDBNameNotSpecified = errors.New("--db-name must be specified")
	ErrDBUserNotSpecified = errors.New("--db-user must be specified")
	ErrDBPortNotSpecified = errors.New("--db-port must be specified")
)
View Source
var ErrDefaultSourceRemoteNotSpecified = errors.New("--default-source-remote must be specified")

Functions

func NewCmdServer

func NewCmdServer() *cobra.Command

Types

type DatabaseAccessOptions

type DatabaseAccessOptions struct {
	DBName     string `json:"dbName,omitempty" yaml:"dbName,omitempty"`
	DBUser     string `json:"dbUser,omitempty" yaml:"dbUser,omitempty"`
	DBPassword string `json:"dbPassword,omitempty" yaml:"dbPassword,omitempty"`
	DBHost     string `json:"dbHost,omitempty" yaml:"dbHost,omitempty"`
	DBPort     int    `json:"dbPort,omitempty" yaml:"dbPort,omitempty"`
}

DatabaseAccessOptions holds the database access layer configurations.

func (*DatabaseAccessOptions) AddFlags

func (o *DatabaseAccessOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to DB to a specified FlagSet

func (*DatabaseAccessOptions) ApplyTo

func (o *DatabaseAccessOptions) ApplyTo(db **gorm.DB) error

ApplyTo uses the run options to generate and open a db session.

func (*DatabaseAccessOptions) InstallDB

func (o *DatabaseAccessOptions) InstallDB() (*gorm.DB, error)

InstallDB uses the run options to generate and open a db session.

func (*DatabaseAccessOptions) Validate

func (o *DatabaseAccessOptions) Validate() error

Validate checks validation of DatabaseAccessOptions

type DatabaseOptions

type DatabaseOptions struct {
	DatabaseAccessOptions `json:",inline" yaml:",inline"`
	// AutoMigrate will attempt to automatically migrate all tables
	AutoMigrate bool   `json:"autoMigrate,omitempty" yaml:"autoMigrate,omitempty"`
	MigrateFile string `json:"migrateFile,omitempty" yaml:"migrateFile,omitempty"`
}

DatabaseOptions is a Database options struct

func NewDatabaseOptions

func NewDatabaseOptions() *DatabaseOptions

NewDatabaseOptions returns a DatabaseOptions instance with the default values

func (*DatabaseOptions) AddFlags

func (o *DatabaseOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags for a specific Option to the specified FlagSet

func (*DatabaseOptions) ApplyTo

func (o *DatabaseOptions) ApplyTo(config *server.Config)

ApplyTo apply database options to the server config

func (DatabaseOptions) MarshalJSON

func (o DatabaseOptions) MarshalJSON() ([]byte, error)

MarshalJSON is custom marshalling function for masking sensitive field values

func (*DatabaseOptions) Validate

func (o *DatabaseOptions) Validate() error

Validate checks DatabaseOptions and return a slice of found error(s)

type DefaultBackendOptions added in v0.13.0

type DefaultBackendOptions struct {
	BackendName     string `json:"backendName,omitempty" yaml:"backendName,omitempty"`
	BackendType     string `json:"backendType,omitempty" yaml:"backendType,omitempty"`
	BackendEndpoint string `json:"backendEndpoint,omitempty" yaml:"backendEndpoint,omitempty"`
}

DefaultBackendOptions holds the default backend access layer configurations.

func (*DefaultBackendOptions) AddFlags added in v0.13.0

func (o *DefaultBackendOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to backend to a specified FlagSet

func (*DefaultBackendOptions) ApplyTo added in v0.13.0

func (o *DefaultBackendOptions) ApplyTo(config *server.Config) error

ApplyTo uses the run options to read and set the default backend access layer configurations

type DefaultSourceOptions added in v0.13.0

type DefaultSourceOptions struct {
	SourceRemote string `json:"sourceRemote,omitempty" yaml:"sourceRemote,omitempty"`
}

DefaultSourceOptions holds the default backend access layer configurations.

func (*DefaultSourceOptions) AddFlags added in v0.13.0

func (o *DefaultSourceOptions) AddFlags(fs *pflag.FlagSet)

AddFlags adds flags related to backend to a specified FlagSet

func (*DefaultSourceOptions) ApplyTo added in v0.13.0

func (o *DefaultSourceOptions) ApplyTo(config *server.Config) error

ApplyTo uses the run options to read and set the default backend access layer configurations

func (*DefaultSourceOptions) Validate added in v0.13.0

func (o *DefaultSourceOptions) Validate() error

Validate checks validation of DefaultSourceOptions

type Options

type Options interface {
	// Validate checks Options and return a slice of found error(s)
	Validate() error
	// AddFlags adds flags for a specific Option to the specified FlagSet
	AddFlags(fs *pflag.FlagSet)
}

type ServerOptions

type ServerOptions struct {
	Mode           string
	Port           int
	AuthEnabled    bool
	AuthWhitelist  []string
	AuthKeyType    string
	Database       DatabaseOptions
	DefaultBackend DefaultBackendOptions
	DefaultSource  DefaultSourceOptions
	MaxConcurrent  int
	LogFilePath    string
}

func NewServerOptions

func NewServerOptions() *ServerOptions

func (*ServerOptions) AddServerFlags

func (o *ServerOptions) AddServerFlags(cmd *cobra.Command)

func (*ServerOptions) Complete

func (o *ServerOptions) Complete(args []string)

func (*ServerOptions) Config

func (o *ServerOptions) Config() (*server.Config, error)

func (*ServerOptions) Run

func (o *ServerOptions) Run() error

func (*ServerOptions) Validate

func (o *ServerOptions) Validate() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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