server

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsImageError added in v0.0.9

func IsImageError(err error) bool

IsImageError checks if the error is an image generation error

func IsInvalidRequest added in v0.0.9

func IsInvalidRequest(err error) bool

IsInvalidRequest checks if the error is an invalid request error

func IsNoPortAvailable added in v0.0.9

func IsNoPortAvailable(err error) bool

IsNoPortAvailable checks if the error is a no port available error

func IsSSHNotAvailable added in v0.0.9

func IsSSHNotAvailable(err error) bool

IsSSHNotAvailable checks if the error is an SSH not available error

func IsTunnelError added in v0.0.9

func IsTunnelError(err error) bool

IsTunnelError checks if the error is a tunnel error

Types

type Error added in v0.0.9

type Error struct {
	Code    ErrorCode
	Message string
	Err     error
}

Error represents a server error

func NewError added in v0.0.9

func NewError(code ErrorCode, message string, err error) *Error

NewError creates a new server error

func (*Error) Error added in v0.0.9

func (e *Error) Error() string

Error implements the error interface

func (*Error) Unwrap added in v0.0.9

func (e *Error) Unwrap() error

Unwrap returns the underlying error

type ErrorCode added in v0.0.9

type ErrorCode int

ErrorCode represents different types of server errors

const (
	ErrSSHNotAvailable ErrorCode = iota + 1
	ErrNoPortAvailable
	ErrTunnelStart
	ErrImageGeneration
	ErrInvalidRequest
	ErrServerStart
	ErrServerShutdown
)

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server represents the main application server

func New

func New(cfg *config.Config, opts ...ServerOption) *Server

New creates a new server instance

func (*Server) Done added in v0.0.9

func (s *Server) Done() <-chan struct{}

Done returns the done channel

func (*Server) MessageChan added in v0.0.9

func (s *Server) MessageChan() <-chan types.Message

MessageChan returns the message channel

func (*Server) Ready

func (s *Server) Ready() <-chan struct{}

Ready returns the ready channel

func (*Server) SendPostRequest

func (s *Server) SendPostRequest(ctx context.Context, url, key, model string, useStream bool)

SendPostRequest sends a POST request to test the API

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown gracefully shuts down the server

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the server

func (*Server) TunnelURL

func (s *Server) TunnelURL() string

TunnelURL returns the tunnel URL

type ServerOption added in v0.0.9

type ServerOption func(*Server)

ServerOption represents a server configuration option

func WithHTTPServer added in v0.0.9

func WithHTTPServer(server interfaces.HTTPServer) ServerOption

WithHTTPServer sets a custom HTTP server

func WithImageGenerator added in v0.0.9

func WithImageGenerator(ig interfaces.ImageGenerator) ServerOption

WithImageGenerator sets a custom image generator

func WithRouter added in v0.0.9

func WithRouter(router interfaces.Router) ServerOption

WithRouter sets a custom router

func WithTunnel added in v0.0.9

func WithTunnel(t interfaces.Tunnel) ServerOption

WithTunnel sets a custom tunnel

Jump to

Keyboard shortcuts

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