Documentation
¶
Overview ¶
The commmon package provides structs and functions for external code to interact with this gateway service.
Index ¶
- Constants
- Variables
- func GetMessageBusAddress(runtimePath string) (string, error)
- func GetPublicKey(runtimePath string) (*ecdsa.PublicKey, error)
- func ListenGatewayPortChanges(ctx context.Context, callback GatewayPortChangeCallback, ...) error
- func PrintEventTypesAsMarkdown(sourceID, version string, eventTypes []EventType)
- func PublishEventInSocket(ctx context.Context, SourceID string, Name string, ...) (*http.Response, error)
- type AppManageService
- type EventType
- type GatewayPortChangeCallback
- type GatewayPortConfig
- type GatewayPortWatcher
- type GatewayPortWatcherOption
- type ManagementService
- type NotifyService
- type NvidiaGPUInfo
- type ParsedToken
- type PropertyType
- type ShareService
Constants ¶
const ( AppManageURLFilename = "app-management.url" APIComposeInfo = "/v2/app_management/compose" APIComposeStatus = "/v2/app_management/compose" )
const ( ManagementURLFilename = "management.url" StaticURLFilename = "static.url" APIGatewayRoutes = "/v1/gateway/routes" APIGatewayPort = "/v1/gateway/port" )
const ( // GatewayConfigFilename is the gateway config file name under /etc/casaos. GatewayConfigFilename = "gateway.ini" // DefaultGatewayPortWatcherPollInterval is used when fsnotify is unavailable. DefaultGatewayPortWatcherPollInterval = time.Second )
const ( MessageBusAddressFilename = "message-bus.url" APIMessageBus = "/v2/message_bus" )
const ( CasaOSURLFilename = "casaos.url" APICasaOSNotify = "/v1/notify" )
const ( UserServiceAddressFilename = "user-service.url" GatewaySockFilename = "zimaos-gateway.sock" )
const (
)
Variables ¶
var ( // DefaultGatewayConfigPath is the default gateway config file path. DefaultGatewayConfigPath = filepath.Join(constants.DefaultConfigPath, GatewayConfigFilename) )
Functions ¶
func GetMessageBusAddress ¶
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
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.
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 ShareService ¶
type ShareService interface {
}
func NewShareService ¶
func NewShareService(runtimePath string) ShareService