Documentation
¶
Overview ¶
Package server ties together the pieces of the luce server process: HTTP routes over tools/server/core, users and sessions through util/lusers and lusess, an admin CLI, and the service-registration socket that external services connect to.
Index ¶
- Variables
- type AdminLockUserCreationReq
- type AdminLockUserCreationResp
- type BashCmd
- type BashCommandOuputReq
- type BashCommandOuputResp
- type Config
- type CreateUserReq
- type CreateUserResp
- type GroupReq
- type GroupResp
- type ListBashCommandsReq
- type ListBashCommandsResp
- type ListGroupsReq
- type ListGroupsResp
- type ListServicesReq
- type ListServicesResp
- type ListUsersReq
- type ListUsersResp
- type RoutesReq
- type RoutesResp
- type RunBashCommandReq
- type RunBashCommandResp
- type Server
- type SetPortReq
- type SetPortResp
- type Settings
- type SettingsReq
- type TemplateNames
- type UserGroupReq
- type UserGroupResp
- type WebSocket
Constants ¶
This section is empty.
Variables ¶
var DefaultExitDelay = 500 * time.Millisecond
DefaultExitDelay is the ExitDelay used when Config leaves it zero. It gives the services started by BashCommands time to clean up, removing their socket files, after their connections close and before the server exits.
var TimeoutDuration = time.Second * 5
TimeoutDuration bounds how long RunServiceSocket waits for a registered service to respond to a proxied request before replying 408 Request Timeout.
Functions ¶
This section is empty.
Types ¶
type AdminLockUserCreationReq ¶
type AdminLockUserCreationReq struct {
AdminLockUserCreation bool
}
AdminLockUserCreationReq sets whether new users may only be created by an admin.
type AdminLockUserCreationResp ¶
type AdminLockUserCreationResp struct{}
AdminLockUserCreationResp confirms AdminLockUserCreationReq.
type BashCmd ¶
type BashCmd struct {
Format string
Auto bool
Args slice.Slice[any]
// contains filtered or unexported fields
}
BashCmd is a configured shell command the admin CLI can run and inspect.
type BashCommandOuputReq ¶
type BashCommandOuputReq struct {
ID int
}
BashCommandOuputReq requests the buffered output of the bash command at index ID.
type BashCommandOuputResp ¶
type BashCommandOuputResp struct {
Msg string
}
BashCommandOuputResp is the output returned by BashCommandOuputReq.
type Config ¶
type Config struct {
SessionStore sessions.Store
Templates *template.Template
UserStore store.NestedFactory
TemplateNames
ServiceSocket string
core.Config
BashCommands []BashCmd
Commander lexec.Commander
// ExitDelay is how long Run waits, after the server is shut down, before
// it returns. Zero uses DefaultExitDelay.
ExitDelay time.Duration
}
Config is used to create a Server. It holds all the configuration values. This follows the builder pattern instead of using a function that would take many arguments.
type CreateUserReq ¶
type CreateUserReq struct {
Name, Password string
}
CreateUserReq requests a new user named Name with Password.
type CreateUserResp ¶
type CreateUserResp struct {
Error error
}
CreateUserResp reports whether CreateUserReq failed.
type ListBashCommandsReq ¶
type ListBashCommandsReq struct {
}
ListBashCommandsReq lists the server's configured bash commands.
type ListBashCommandsResp ¶
type ListBashCommandsResp []BashCmd
ListBashCommandsResp is the bash commands returned by ListBashCommandsReq.
type ListGroupsResp ¶
type ListGroupsResp []string
ListGroupsResp is the group names returned by ListGroupsReq.
type ListServicesReq ¶
type ListServicesReq struct {
}
ListServicesReq lists the services currently registered over the service socket.
type ListServicesResp ¶
type ListServicesResp []string
ListServicesResp is the registered service names returned by ListServicesReq.
type ListUsersResp ¶
type ListUsersResp []string
ListUsersResp is the user names returned by ListUsersReq.
type RoutesReq ¶
type RoutesReq struct {
}
RoutesReq requests the server's currently active service routes.
type RoutesResp ¶
type RoutesResp string
RoutesResp lists the active service routes, one per line, returned by RoutesReq.
type RunBashCommandReq ¶
type RunBashCommandReq struct {
ID int
}
RunBashCommandReq runs the configured bash command at index ID.
type RunBashCommandResp ¶
type RunBashCommandResp struct {
Msg string
}
RunBashCommandResp reports the result of RunBashCommandReq.
type Server ¶
type Server struct {
Users *lusess.Store
Settings Settings
Templates *template.Template
ServiceSocket string
TemplateNames
lerr.ErrHandler
BashCommands slice.Slice[BashCmd]
Commander lexec.Commander
WebSocket
// contains filtered or unexported fields
}
Server runs a webserver.
func (*Server) Run ¶
func (s *Server) Run()
Run the server. If Socket or ServiceSocket is defined, they will be run as well. It blocks until the server stops. When it was stopped by a shutdown, such as the CLI's close command, it waits ExitDelay before it returns.
func (*Server) RunServiceSocket ¶
RunServiceSocket listens on the configured service socket, blocking until it stops. External services connect here to register their routes and handle proxied requests.
type SetPortReq ¶
type SetPortReq struct {
Port string
}
SetPortReq changes the HTTP server's listening port.
type SetPortResp ¶
type SetPortResp struct{}
SetPortResp confirms SetPortReq; the server has already restarted.
type Settings ¶
type Settings struct {
AdminLockUserCreation bool
}
Settings holds the server's admin-configurable settings.
type TemplateNames ¶
TemplateNames names the templates Server renders for the built-in user pages.
type UserGroupReq ¶
type UserGroupReq struct {
User, Group string
}
UserGroupReq adds User to Group.
type UserGroupResp ¶
type UserGroupResp struct {
Error error
}
UserGroupResp reports whether UserGroupReq failed.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package core runs the HTTP and unix-socket plumbing for a luce server: starting and stopping the web server, and exposing the same process over an admin CLI socket.
|
Package core runs the HTTP and unix-socket plumbing for a luce server: starting and stopping the web server, and exposing the same process over an admin CLI socket. |
|
Package service is the protocol a tools/server service registers and communicates with over the admin's service socket: requests, responses, routes, and the client that connects a service to the server.
|
Package service is the protocol a tools/server service registers and communicates with over the admin's service socket: requests, responses, routes, and the client that connects a service to the server. |