core

package
v0.0.0-...-56e812d Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.0.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	Run(core *Core, r *com.Request, m *ModuleConfig, args ...string) (string, error)
	Error() error
	GetResult() string

	GetName() string
	// contains filtered or unexported methods
}

Command - Command interface

type CommandProcessor

type CommandProcessor interface {
	Register(name string, run func(*Core, *com.Request, *ModuleConfig, ...string) (string, error)) bool
	Run(name string, r com.Request, m ModuleConfig, args ...string) Command
}

CommandProcessor - CommandProcessor

type CommandProcessorImpl

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

CommandProcessorImpl -

func (*CommandProcessorImpl) Init

func (cp *CommandProcessorImpl) Init()

Init - Init CommandProcessorImpl with default commands

func (*CommandProcessorImpl) Register

func (cp *CommandProcessorImpl) Register(name string, run func(*Core, *com.Request, *ModuleConfig, ...string) (string, error))

Register - Register new ModuleCommand in CommandProcessorImpl

func (*CommandProcessorImpl) Run

func (cp *CommandProcessorImpl) Run(name string, core *Core, r *com.Request, m *ModuleConfig, args ...string) (string, error)

Run - Run command in CommandProcessorImpl

type Config

type Config struct {
	ACCESSLOGFILE string
	MODULES       map[string]ModuleConfig
	MOTD          string
	NAME          string
	SECRET        string
	MODDIR        string
	RESOURCEDIR   string
	SERVER        com.ServerConfig
	VERSION       int
}

Config - Global configuration

func (*Config) GetMotdFileContent

func (c *Config) GetMotdFileContent() string

GetMotdFileContent - Get motd file content from motd path

func (*Config) LoadConfig

func (c *Config) LoadConfig(path string) (err error)

type Core

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

Core - GO-WOXY Core Server

func (*Core) APIKeyMatch

func (core *Core) APIKeyMatch(key string) bool

APIKeyMatch - Check if given key match api key hash

func (*Core) GetCommandProcessor

func (core *Core) GetCommandProcessor() *CommandProcessorImpl

GetCommandProcessor - Get CommandProcessor

func (*Core) GetConfig

func (core *Core) GetConfig() Config

GetConfig - Get go-woxy config

func (*Core) GetLogger

func (core *Core) GetLogger(name string) *logrus.Logger

func (*Core) GetModule

func (core *Core) GetModule(name string) *ModuleConfig

GetModule - Get module reference from core list module

func (*Core) GetServer

func (core *Core) GetServer() *HttpServer

GetServer - Get server

func (*Core) GetSupervisor

func (core *Core) GetSupervisor() *Supervisor

GetSupervisor - Get module supervisor

func (*Core) GoWoxy

func (core *Core) GoWoxy(configPath string)

GoWoxy - start core server

func (*Core) Hook

func (core *Core) Hook(mc *ModuleConfig, r com.Route) error

Hook - Create a binding between module and router server

func (*Core) HookAll

func (core *Core) HookAll(mc *ModuleConfig)

HookAll - Create all binding between module config address and router server

func (*Core) SaveModuleChanges

func (core *Core) SaveModuleChanges(mc *ModuleConfig)

SaveModuleChanges - Thread safe way to edit Module state

func (*Core) SearchModWithHash

func (core *Core) SearchModWithHash(hash string) *ModuleConfig

SearchModWithHash - Thread safe way to get module with his hash

func (*Core) SetServer

func (core *Core) SetServer(s *HttpServer)

SetServer - Set server

func (*Core) Setup

func (core *Core) Setup(mc ModuleConfig, hook bool, modulePath string) (*ModuleConfig, error)

Setup - Setup module from config

type Entity

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

Entity -

type HttpServer

type HttpServer struct {
	http.Server
	// contains filtered or unexported fields
}

HttpServer -

func (*HttpServer) WaitShutdown

func (s *HttpServer) WaitShutdown()

WaitShutdown - Wait server to shutdown correctly

type ModuleAuthConfig

type ModuleAuthConfig struct {
	ENABLED bool
	TYPE    string
}

ModuleAuthConfig - ModuleConfig Auth configuration

type ModuleCommand

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

ModuleCommand - Command implementation

func (*ModuleCommand) Error

func (mc *ModuleCommand) Error() error

Error - Get command execution error

func (*ModuleCommand) GetName

func (mc *ModuleCommand) GetName() string

GetName - Get command name

func (*ModuleCommand) GetResult

func (mc *ModuleCommand) GetResult() string

GetResult - Get command result

func (*ModuleCommand) Run

func (mc *ModuleCommand) Run(core *Core, r *com.Request, m *ModuleConfig, args ...string) (string, error)

Run - Command

type ModuleConfig

type ModuleConfig struct {
	API_KEY  string
	AUTH     ModuleAuthConfig
	BINDING  com.ServerConfig
	COMMANDS []string
	EXE      ModuleExecConfig
	NAME     string

	PK           string
	RESOURCEPATH string
	LOG          ModuleLogConfig
	STATE        com.ModuleState
	TYPES        string
	VERSION      int
	// contains filtered or unexported fields
}

ModuleConfig - Module configuration

func (*ModuleConfig) Download

func (mc *ModuleConfig) Download(moduleDir string)

Download - Download module from repository ( git clone )

func (*ModuleConfig) GetLog

func (mc *ModuleConfig) GetLog() string

GetLog - GetLog from Module

func (*ModuleConfig) GetPerf

func (mc *ModuleConfig) GetPerf() (float64, float32)

GetPerf - GetPerf from Module

func (*ModuleConfig) GetServer

func (mc *ModuleConfig) GetServer(path string) com.Server

GetServer - Get Module Server configuration

func (*ModuleConfig) Start

func (mc *ModuleConfig) Start()

Start - Start module with config args and auto args

type ModuleExecConfig

type ModuleExecConfig struct {
	BIN        string
	MAIN       string
	REMOTE     bool
	SRC        string
	SUPERVISED bool
	LastPing   time.Time
}

ModuleExecConfig - Module exec file informations

type ModuleLogConfig

type ModuleLogConfig struct {
	Enabled *bool  `yaml:"enabled"`
	File    string `yaml:"file"`
	Path    string `yaml:"path"`
}

ModuleLogConfig - Module Logging Configuration

func (*ModuleLogConfig) IsEnabled

func (mlc *ModuleLogConfig) IsEnabled() bool

type Role

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

Role - Module Role

type Supervisor

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

Supervisor -

func (*Supervisor) Add

func (s *Supervisor) Add(m string)

Add -

func (*Supervisor) Remove

func (s *Supervisor) Remove(m string)

Remove -

func (*Supervisor) SetCore

func (s *Supervisor) SetCore(core *Core)

SetCore - Set core

func (*Supervisor) Supervise

func (s *Supervisor) Supervise()

Supervise -

Jump to

Keyboard shortcuts

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