external

package
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: Apache-2.0 Imports: 29 Imported by: 41

Documentation

Overview

The commmon package provides structs and functions for external code to interact with this gateway service.

Index

Constants

View Source
const (
	AppManageURLFilename = "app-management.url"
	APIComposeInfo       = "/v2/app_management/compose"
	APIComposeStatus     = "/v2/app_management/compose"
)
View Source
const (
	ManagementURLFilename = "management.url"
	StaticURLFilename     = "static.url"
	APIGatewayRoutes      = "/v1/gateway/routes"
	APIGatewayPort        = "/v1/gateway/port"
)
View Source
const (
	// GatewayConfigFilename is the gateway config file name under /etc/casaos.
	GatewayConfigFilename = "gateway.ini"
	// DefaultGatewayPortWatcherPollInterval is used when fsnotify is unavailable.
	DefaultGatewayPortWatcherPollInterval = time.Second
)
View Source
const (
	MessageBusAddressFilename = "message-bus.url"
	APIMessageBus             = "/v2/message_bus"
)
View Source
const (
	CasaOSURLFilename = "casaos.url"
	APICasaOSNotify   = "/v1/notify"
)
View Source
const (
	UserServiceAddressFilename = "user-service.url"
	GatewaySockFilename        = "zimaos-gateway.sock"
)
View Source
const (
	APICasaOSShare = "/v1/samba/shares"
)

Variables

View Source
var (
	// DefaultGatewayConfigPath is the default gateway config file path.
	DefaultGatewayConfigPath = filepath.Join(constants.DefaultConfigPath, GatewayConfigFilename)
)

Functions

func GetMessageBusAddress

func GetMessageBusAddress(runtimePath string) (string, error)

func GetPublicKey added in v0.4.4

func GetPublicKey(runtimePath string) (*ecdsa.PublicKey, error)

func ListenGatewayPortChanges added in v0.4.19

func ListenGatewayPortChanges(ctx context.Context, callback GatewayPortChangeCallback, opts ...GatewayPortWatcherOption) error

ListenGatewayPortChanges watches gateway.ini until ctx is canceled.

func PrintEventTypesAsMarkdown added in v0.4.8

func PrintEventTypesAsMarkdown(sourceID, version string, eventTypes []EventType)

func PublishEventInSocket added in v0.4.8

func PublishEventInSocket(ctx context.Context, SourceID string, Name string, properties map[string]string) (*http.Response, error)

Types

type AppManageService added in v0.4.8

type AppManageService interface {
	GetAppInfo(storeId string) (model.ComposeAppWithStoreInfo, error)
	PutAppStatus(storeId string, status string) (bool, error)
}

func NewAppManageService added in v0.4.8

func NewAppManageService(RuntimePath string) (AppManageService, error)

type EventType added in v0.4.8

type EventType struct {
	Name             string
	SourceID         string
	PropertyTypeList []PropertyType
}

type GatewayPortChangeCallback added in v0.4.19

type GatewayPortChangeCallback func(config GatewayPortConfig)

GatewayPortChangeCallback receives valid gateway port config changes.

type GatewayPortConfig added in v0.4.19

type GatewayPortConfig struct {
	HTTPEnabled  bool `json:"http_enabled"`
	HTTPPort     int  `json:"http_port"`
	HTTPSPort    int  `json:"https_port"`
	HTTPSEnabled bool `json:"https_enabled"`
}

GatewayPortConfig contains gateway HTTP and HTTPS listen settings.

func ReadGatewayPortConfig added in v0.4.19

func ReadGatewayPortConfig(configPath string) (GatewayPortConfig, error)

ReadGatewayPortConfig reads HTTP and HTTPS port settings from gateway.ini.

type GatewayPortWatcher added in v0.4.19

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

GatewayPortWatcher watches gateway.ini with fsnotify first and polling as fallback.

func NewGatewayPortWatcher added in v0.4.19

func NewGatewayPortWatcher(callback GatewayPortChangeCallback, opts ...GatewayPortWatcherOption) *GatewayPortWatcher

NewGatewayPortWatcher creates a gateway port watcher.

func (*GatewayPortWatcher) Watch added in v0.4.19

func (w *GatewayPortWatcher) Watch(ctx context.Context) error

Watch blocks until ctx is canceled. It uses fsnotify first, then falls back to polling by mtime and size.

type GatewayPortWatcherOption added in v0.4.19

type GatewayPortWatcherOption func(*GatewayPortWatcher)

GatewayPortWatcherOption configures GatewayPortWatcher.

func WithGatewayPortConfigPath added in v0.4.19

func WithGatewayPortConfigPath(configPath string) GatewayPortWatcherOption

WithGatewayPortConfigPath overrides the gateway.ini path.

func WithGatewayPortPollInterval added in v0.4.19

func WithGatewayPortPollInterval(interval time.Duration) GatewayPortWatcherOption

WithGatewayPortPollInterval overrides the fallback polling interval.

type ManagementService

type ManagementService interface {
	CreateRoute(route *model.Route) error
	ChangePort(request *model.ChangePortRequest) error
	GetPort() (error, string)
}

func NewManagementService

func NewManagementService(RuntimePath string) (ManagementService, error)

type NotifyService

type NotifyService interface {
	SendNotify(path string, message interface{}) error
	SendSystemStatusNotify(message map[string]interface{}) error
}

func NewNotifyService

func NewNotifyService(runtimePath string) NotifyService

type NvidiaGPUInfo added in v0.4.8

type NvidiaGPUInfo struct {
	Index         int
	UUID          string
	DriverVersion string
	Name          string
	GPUSerial     string
}

func NvidiaGPUInfoList added in v0.4.8

func NvidiaGPUInfoList() ([]NvidiaGPUInfo, error)

func NvidiaGPUInfoListWithSMI added in v0.4.10

func NvidiaGPUInfoListWithSMI() ([]NvidiaGPUInfo, error)

type ParsedToken added in v0.4.17

type ParsedToken struct {
	Valid     bool   `json:"valid"`
	ExpiresAt int64  `json:"expires_at"`
	Username  string `json:"username"`
	Role      string `json:"role"`
	UserID    int    `json:"user_id"`
}

func ParseToken added in v0.4.17

func ParseToken(token string) (*ParsedToken, error)

type PropertyType added in v0.4.8

type PropertyType struct {
	Name        string
	Description *string
	Example     *string
}

type ShareService

type ShareService interface {
	DeleteShare(id string) error
}

func NewShareService

func NewShareService(runtimePath string) ShareService

Jump to

Keyboard shortcuts

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