Documentation ¶
Index ¶
Constants ¶
This section is empty.
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 CreateOptions ¶
type FindOneOptions ¶
type FindOneOptions struct { IdOption *IdOption NameOption *NameOption }
func (*FindOneOptions) Validate ¶
func (options *FindOneOptions) Validate() error
type FindOptions ¶
type Hook ¶
type Hook struct { Command string RunOnCreate bool RunOnUpdate bool RunOnDelete bool RunOnStart bool RunOnStop bool }
func (*Hook) ShouldExecute ¶
func (h *Hook) ShouldExecute(action HookAction) bool
type HookAction ¶
type HookAction string
var ( HookActionCreate HookAction = "CREATE" HookActionUpdate HookAction = "UPDATE" HookActionDelete HookAction = "DELETE" HookActionStart HookAction = "START" HookActionStop HookAction = "STOP" )
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 Hooks []*Hook CreateUserId string UpdateUserId string DeleteUserId string CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time }
func (*Server) RunHooks ¶
func (s *Server) RunHooks(action HookAction) error
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) }
func NewService ¶
func NewService(serverRepository Repository) Service
type UpdateFieldMask ¶
Click to show internal directories.
Click to hide internal directories.