server

package
v0.0.18 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ChangedActionCreated               = "CREATED"
	ChangedActionUpdated               = "UPDATED"
	ChangedActionDeleted               = "DELETED"
	ChangedActionInterfaceStatsUpdated = "INTERFACE_STATS_UPDATED"
	ChangedActionStarted               = "STARTED"
	ChangedActionStopped               = "STOPPED"
)

Variables

View Source
var (
	ErrIdRequired                    = errors.New("id is required")
	ErrNameRequired                  = errors.New("name is required")
	ErrInvalidName                   = errors.New("name is invalid")
	ErrOneOptionRequired             = errors.New("one option is required")
	ErrOnlyOneOptionAllowed          = errors.New("only one option is allowed")
	ErrServerNotFound                = errors.New("server not found")
	ErrServerIdAlreadyExists         = errors.New("server id already exists")
	ErrServerNameAlreadyInUse        = errors.New("name is already in use")
	ErrInvalidMtu                    = errors.New("invalid MTU must be between 1280 and 1500")
	ErrCreateServerOptionsRequired   = errors.New("create server options are required")
	ErrUpdateServerOptionsRequired   = errors.New("update server options are required")
	ErrUpdateServerFieldMaskRequired = errors.New("update server field mask are required")
)

Functions

This section is empty.

Types

type ChangedEvent

type ChangedEvent struct {
	Action string  `json:"action"`
	Server *Server `json:"server"`
}

type CreateOptions

type CreateOptions struct {
	Name         string
	Description  string
	Enabled      bool
	Running      bool
	PrivateKey   string
	ListenPort   *int
	FirewallMark *int
	Address      string
	DNS          []string
	MTU          int
	Stats        Stats
	Hooks        []*Hook
}

type FindOneOptions

type FindOneOptions struct {
	IdOption   *IdOption
	NameOption *NameOption
}

func (*FindOneOptions) Validate

func (options *FindOneOptions) Validate() error

type FindOptions

type FindOptions struct {
	Ids          []string
	Query        string
	Enabled      *bool
	CreateUserId *string
	UpdateUserId *string
}

type Hook

type Hook struct {
	Command     string
	RunOnCreate bool
	RunOnUpdate bool
	RunOnDelete bool
	RunOnStart  bool
	RunOnStop   bool
}

type HookAction

type HookAction string
var (
	HookActionCreate HookAction = "CREATE"
	HookActionUpdate HookAction = "UPDATE"
	HookActionDelete HookAction = "DELETE"
	HookActionStart  HookAction = "START"
	HookActionStop   HookAction = "STOP"
)

type IdOption

type IdOption struct {
	Id string
}

func (*IdOption) Validate

func (option *IdOption) Validate() error

type NameOption

type NameOption struct {
	Name string
}

func (*NameOption) Validate

func (option *NameOption) Validate() error

type Repository

type Repository interface {
	FindOne(ctx context.Context, options *FindOneOptions) (*Server, error)
	FindAll(ctx context.Context, options *FindOptions) ([]*Server, error)
	Create(ctx context.Context, server *Server) (*Server, error)
	Update(ctx context.Context, server *Server, fieldMask *UpdateFieldMask) (*Server, error)
	Delete(ctx context.Context, serverId string, deleteUserId string) (*Server, error)
}

type Server

type Server struct {
	Id           string
	Name         string
	Description  string
	Enabled      bool
	Running      bool
	PublicKey    string
	PrivateKey   string
	ListenPort   *int
	FirewallMark *int
	Address      string
	DNS          []string
	MTU          int
	Stats        Stats
	Hooks        []*Hook
	CreateUserId string
	UpdateUserId string
	DeleteUserId string
	CreatedAt    time.Time
	UpdatedAt    time.Time
	DeletedAt    *time.Time
}

type Service

type Service interface {
	FindServer(ctx context.Context, options *FindOneOptions) (*Server, error)
	FindServers(ctx context.Context, options *FindOptions) ([]*Server, error)
	CreateServer(ctx context.Context, options *CreateOptions, userId string) (*Server, error)
	UpdateServer(ctx context.Context, serverId string, options *UpdateOptions, fieldMask *UpdateFieldMask, userId string) (*Server, error)
	DeleteServer(ctx context.Context, serverId string, userId string) (*Server, error)
	Subscribe(ctx context.Context) (<-chan *ChangedEvent, error)
	HasSubscribers() bool
}

func NewService

func NewService(serverRepository Repository, transactionScoper dbx.TransactionScoper, subscription subscription.Subscription) Service

type Stats

type Stats struct {
	RxPackets         uint64
	TxPackets         uint64
	RxBytes           uint64
	TxBytes           uint64
	RxErrors          uint64
	TxErrors          uint64
	RxDropped         uint64
	TxDropped         uint64
	Multicast         uint64
	Collisions        uint64
	RxLengthErrors    uint64
	RxOverErrors      uint64
	RxCrcErrors       uint64
	RxFrameErrors     uint64
	RxFifoErrors      uint64
	RxMissedErrors    uint64
	TxAbortedErrors   uint64
	TxCarrierErrors   uint64
	TxFifoErrors      uint64
	TxHeartbeatErrors uint64
	TxWindowErrors    uint64
	RxCompressed      uint64
	TxCompressed      uint64
}

type UpdateFieldMask

type UpdateFieldMask struct {
	Description  bool
	Enabled      bool
	Running      bool
	PrivateKey   bool
	ListenPort   bool
	FirewallMark bool
	Address      bool
	DNS          bool
	MTU          bool
	Stats        bool
	Hooks        bool
	CreateUserId bool
	UpdateUserId bool
}

type UpdateOptions

type UpdateOptions struct {
	Description  string
	Enabled      bool
	Running      bool
	PrivateKey   string
	ListenPort   *int
	FirewallMark *int
	Address      string
	DNS          []string
	MTU          int
	Stats        Stats
	Hooks        []*Hook
	CreateUserId string
	UpdateUserId string
}

Jump to

Keyboard shortcuts

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