mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
add context to rooms.
This commit is contained in:
+18
-17
@@ -1,6 +1,7 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
@@ -26,7 +27,7 @@ func (manager *ApiManagerCtx) roomsList(w http.ResponseWriter, r *http.Request)
|
||||
labelsMap[key] = value[0]
|
||||
}
|
||||
|
||||
response, err := manager.rooms.List(labelsMap)
|
||||
response, err := manager.rooms.List(r.Context(), labelsMap)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
@@ -50,20 +51,20 @@ func (manager *ApiManagerCtx) roomCreate(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
ID, err := manager.rooms.Create(request)
|
||||
ID, err := manager.rooms.Create(r.Context(), request)
|
||||
if err != nil {
|
||||
manager.logger.Error().Err(err).Msg("create: failed to create room")
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
if err := manager.rooms.Start(ID); err != nil {
|
||||
if err := manager.rooms.Start(r.Context(), ID); err != nil {
|
||||
manager.logger.Error().Err(err).Msg("create: failed to start room")
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
response, err := manager.rooms.GetEntry(ID)
|
||||
response, err := manager.rooms.GetEntry(r.Context(), ID)
|
||||
if err != nil {
|
||||
manager.logger.Error().Err(err).Msg("create: failed to get room entry")
|
||||
http.Error(w, err.Error(), 500)
|
||||
@@ -77,7 +78,7 @@ func (manager *ApiManagerCtx) roomCreate(w http.ResponseWriter, r *http.Request)
|
||||
func (manager *ApiManagerCtx) roomRecreate(w http.ResponseWriter, r *http.Request) {
|
||||
roomId := chi.URLParam(r, "roomId")
|
||||
|
||||
entry, err := manager.rooms.GetEntry(roomId)
|
||||
entry, err := manager.rooms.GetEntry(r.Context(), roomId)
|
||||
if err != nil {
|
||||
if errors.Is(err, types.ErrRoomNotFound) {
|
||||
http.Error(w, err.Error(), 404)
|
||||
@@ -88,7 +89,7 @@ func (manager *ApiManagerCtx) roomRecreate(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
settings, err := manager.rooms.GetSettings(roomId)
|
||||
settings, err := manager.rooms.GetSettings(r.Context(), roomId)
|
||||
if err != nil {
|
||||
manager.logger.Error().Err(err).Msg("recreate: failed to get room settings")
|
||||
http.Error(w, err.Error(), 500)
|
||||
@@ -101,13 +102,13 @@ func (manager *ApiManagerCtx) roomRecreate(w http.ResponseWriter, r *http.Reques
|
||||
return
|
||||
}
|
||||
|
||||
if err := manager.rooms.Remove(roomId); err != nil {
|
||||
if err := manager.rooms.Remove(r.Context(), roomId); err != nil {
|
||||
manager.logger.Error().Err(err).Msg("recreate: failed to remove room")
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
|
||||
ID, err := manager.rooms.Create(*settings)
|
||||
ID, err := manager.rooms.Create(r.Context(), *settings)
|
||||
if err != nil {
|
||||
manager.logger.Error().Err(err).Msg("recreate: failed to create room")
|
||||
http.Error(w, err.Error(), 500)
|
||||
@@ -115,14 +116,14 @@ func (manager *ApiManagerCtx) roomRecreate(w http.ResponseWriter, r *http.Reques
|
||||
}
|
||||
|
||||
if entry.Running {
|
||||
if err := manager.rooms.Start(ID); err != nil {
|
||||
if err := manager.rooms.Start(r.Context(), ID); err != nil {
|
||||
manager.logger.Error().Err(err).Msg("recreate: failed to start room")
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
response, err := manager.rooms.GetEntry(ID)
|
||||
response, err := manager.rooms.GetEntry(r.Context(), ID)
|
||||
if err != nil {
|
||||
manager.logger.Error().Err(err).Msg("recreate: failed to get room entry")
|
||||
http.Error(w, err.Error(), 500)
|
||||
@@ -136,7 +137,7 @@ func (manager *ApiManagerCtx) roomRecreate(w http.ResponseWriter, r *http.Reques
|
||||
func (manager *ApiManagerCtx) roomGetEntry(w http.ResponseWriter, r *http.Request) {
|
||||
roomId := chi.URLParam(r, "roomId")
|
||||
|
||||
response, err := manager.rooms.GetEntry(roomId)
|
||||
response, err := manager.rooms.GetEntry(r.Context(), roomId)
|
||||
if err != nil {
|
||||
if errors.Is(err, types.ErrRoomNotFound) {
|
||||
http.Error(w, err.Error(), 404)
|
||||
@@ -154,7 +155,7 @@ func (manager *ApiManagerCtx) roomGetEntryByName(w http.ResponseWriter, r *http.
|
||||
// roomId is actually room name here
|
||||
roomName := chi.URLParam(r, "roomId")
|
||||
|
||||
response, err := manager.rooms.GetEntryByName(roomName)
|
||||
response, err := manager.rooms.GetEntryByName(r.Context(), roomName)
|
||||
if err != nil {
|
||||
if errors.Is(err, types.ErrRoomNotFound) {
|
||||
http.Error(w, err.Error(), 404)
|
||||
@@ -171,7 +172,7 @@ func (manager *ApiManagerCtx) roomGetEntryByName(w http.ResponseWriter, r *http.
|
||||
func (manager *ApiManagerCtx) roomGetSettings(w http.ResponseWriter, r *http.Request) {
|
||||
roomId := chi.URLParam(r, "roomId")
|
||||
|
||||
response, err := manager.rooms.GetSettings(roomId)
|
||||
response, err := manager.rooms.GetSettings(r.Context(), roomId)
|
||||
if err != nil {
|
||||
if errors.Is(err, types.ErrRoomNotFound) {
|
||||
http.Error(w, err.Error(), 404)
|
||||
@@ -188,7 +189,7 @@ func (manager *ApiManagerCtx) roomGetSettings(w http.ResponseWriter, r *http.Req
|
||||
func (manager *ApiManagerCtx) roomGetStats(w http.ResponseWriter, r *http.Request) {
|
||||
roomId := chi.URLParam(r, "roomId")
|
||||
|
||||
response, err := manager.rooms.GetStats(roomId)
|
||||
response, err := manager.rooms.GetStats(r.Context(), roomId)
|
||||
if err != nil {
|
||||
if errors.Is(err, types.ErrRoomNotFound) {
|
||||
http.Error(w, err.Error(), 404)
|
||||
@@ -202,11 +203,11 @@ func (manager *ApiManagerCtx) roomGetStats(w http.ResponseWriter, r *http.Reques
|
||||
json.NewEncoder(w).Encode(response)
|
||||
}
|
||||
|
||||
func (manager *ApiManagerCtx) roomGenericAction(action func(id string) error) func(http.ResponseWriter, *http.Request) {
|
||||
func (manager *ApiManagerCtx) roomGenericAction(action func(ctx context.Context, id string) error) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
roomId := chi.URLParam(r, "roomId")
|
||||
|
||||
err := action(roomId)
|
||||
err := action(r.Context(), roomId)
|
||||
if err != nil {
|
||||
if errors.Is(err, types.ErrRoomNotFound) {
|
||||
http.Error(w, err.Error(), 404)
|
||||
@@ -221,7 +222,7 @@ func (manager *ApiManagerCtx) roomGenericAction(action func(id string) error) fu
|
||||
}
|
||||
|
||||
func (manager *ApiManagerCtx) dockerCompose(w http.ResponseWriter, r *http.Request) {
|
||||
response, err := manager.rooms.ExportAsDockerCompose()
|
||||
response, err := manager.rooms.ExportAsDockerCompose(r.Context())
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), 500)
|
||||
return
|
||||
|
||||
+13
-13
@@ -39,7 +39,7 @@ func (manager *RoomManagerCtx) containerToEntry(container dockerTypes.Container)
|
||||
return entry, nil
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) listContainers(labels map[string]string) ([]dockerTypes.Container, error) {
|
||||
func (manager *RoomManagerCtx) listContainers(ctx context.Context, labels map[string]string) ([]dockerTypes.Container, error) {
|
||||
args := filters.NewArgs(
|
||||
filters.Arg("label", fmt.Sprintf("m1k1o.neko_rooms.instance=%s", manager.config.InstanceName)),
|
||||
)
|
||||
@@ -48,16 +48,16 @@ func (manager *RoomManagerCtx) listContainers(labels map[string]string) ([]docke
|
||||
args.Add("label", fmt.Sprintf("m1k1o.neko_rooms.x-%s=%s", key, val))
|
||||
}
|
||||
|
||||
return manager.client.ContainerList(context.Background(), dockerTypes.ContainerListOptions{
|
||||
return manager.client.ContainerList(ctx, dockerTypes.ContainerListOptions{
|
||||
All: true,
|
||||
Filters: args,
|
||||
})
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) containerFilter(args filters.Args) (*dockerTypes.Container, error) {
|
||||
func (manager *RoomManagerCtx) containerFilter(ctx context.Context, args filters.Args) (*dockerTypes.Container, error) {
|
||||
args.Add("label", fmt.Sprintf("m1k1o.neko_rooms.instance=%s", manager.config.InstanceName))
|
||||
|
||||
containers, err := manager.client.ContainerList(context.Background(), dockerTypes.ContainerListOptions{
|
||||
containers, err := manager.client.ContainerList(ctx, dockerTypes.ContainerListOptions{
|
||||
All: true,
|
||||
Filters: args,
|
||||
})
|
||||
@@ -74,20 +74,20 @@ func (manager *RoomManagerCtx) containerFilter(args filters.Args) (*dockerTypes.
|
||||
return &container, nil
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) containerById(id string) (*dockerTypes.Container, error) {
|
||||
return manager.containerFilter(filters.NewArgs(
|
||||
func (manager *RoomManagerCtx) containerById(ctx context.Context, id string) (*dockerTypes.Container, error) {
|
||||
return manager.containerFilter(ctx, filters.NewArgs(
|
||||
filters.Arg("id", id),
|
||||
))
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) containerByName(name string) (*dockerTypes.Container, error) {
|
||||
return manager.containerFilter(filters.NewArgs(
|
||||
func (manager *RoomManagerCtx) containerByName(ctx context.Context, name string) (*dockerTypes.Container, error) {
|
||||
return manager.containerFilter(ctx, filters.NewArgs(
|
||||
filters.Arg("name", manager.config.InstanceName+"-"+name),
|
||||
))
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) inspectContainer(id string) (*dockerTypes.ContainerJSON, error) {
|
||||
container, err := manager.client.ContainerInspect(context.Background(), id)
|
||||
func (manager *RoomManagerCtx) inspectContainer(ctx context.Context, id string) (*dockerTypes.ContainerJSON, error) {
|
||||
container, err := manager.client.ContainerInspect(ctx, id)
|
||||
if err != nil {
|
||||
if dockerClient.IsErrNotFound(err) {
|
||||
return nil, types.ErrRoomNotFound
|
||||
@@ -103,8 +103,8 @@ func (manager *RoomManagerCtx) inspectContainer(id string) (*dockerTypes.Contain
|
||||
return &container, nil
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) containerExec(id string, cmd []string) (string, error) {
|
||||
exec, err := manager.client.ContainerExecCreate(context.Background(), id, dockerTypes.ExecConfig{
|
||||
func (manager *RoomManagerCtx) containerExec(ctx context.Context, id string, cmd []string) (string, error) {
|
||||
exec, err := manager.client.ContainerExecCreate(ctx, id, dockerTypes.ExecConfig{
|
||||
AttachStderr: true,
|
||||
AttachStdin: true,
|
||||
AttachStdout: true,
|
||||
@@ -119,7 +119,7 @@ func (manager *RoomManagerCtx) containerExec(id string, cmd []string) (string, e
|
||||
return "", err
|
||||
}
|
||||
|
||||
conn, err := manager.client.ContainerExecAttach(context.Background(), exec.ID, dockerTypes.ExecStartCheck{
|
||||
conn, err := manager.client.ContainerExecAttach(ctx, exec.ID, dockerTypes.ExecStartCheck{
|
||||
Detach: false,
|
||||
Tty: true,
|
||||
})
|
||||
|
||||
+30
-30
@@ -64,8 +64,8 @@ func (manager *RoomManagerCtx) Config() types.RoomsConfig {
|
||||
}
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) List(labels map[string]string) ([]types.RoomEntry, error) {
|
||||
containers, err := manager.listContainers(labels)
|
||||
func (manager *RoomManagerCtx) List(ctx context.Context, labels map[string]string) ([]types.RoomEntry, error) {
|
||||
containers, err := manager.listContainers(ctx, labels)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -83,7 +83,7 @@ func (manager *RoomManagerCtx) List(labels map[string]string) ([]types.RoomEntry
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) ExportAsDockerCompose() ([]byte, error) {
|
||||
func (manager *RoomManagerCtx) ExportAsDockerCompose(ctx context.Context) ([]byte, error) {
|
||||
services := map[string]any{}
|
||||
|
||||
dockerCompose := map[string]any{
|
||||
@@ -97,13 +97,13 @@ func (manager *RoomManagerCtx) ExportAsDockerCompose() ([]byte, error) {
|
||||
"services": services,
|
||||
}
|
||||
|
||||
containers, err := manager.listContainers(map[string]string{})
|
||||
containers, err := manager.listContainers(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for _, container := range containers {
|
||||
containerJson, err := manager.inspectContainer(container.ID)
|
||||
containerJson, err := manager.inspectContainer(ctx, container.ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -229,7 +229,7 @@ func (manager *RoomManagerCtx) ExportAsDockerCompose() ([]byte, error) {
|
||||
return yaml.Marshal(dockerCompose)
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) Create(settings types.RoomSettings) (string, error) {
|
||||
func (manager *RoomManagerCtx) Create(ctx context.Context, settings types.RoomSettings) (string, error) {
|
||||
if settings.Name != "" && !dockerNames.RestrictedNamePattern.MatchString(settings.Name) {
|
||||
return "", fmt.Errorf("invalid container name, must match %s", dockerNames.RestrictedNameChars)
|
||||
}
|
||||
@@ -261,7 +261,7 @@ func (manager *RoomManagerCtx) Create(settings types.RoomSettings) (string, erro
|
||||
portsNeeded = 1
|
||||
}
|
||||
|
||||
epr, err := manager.allocatePorts(portsNeeded)
|
||||
epr, err := manager.allocatePorts(ctx, portsNeeded)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
@@ -625,7 +625,7 @@ func (manager *RoomManagerCtx) Create(settings types.RoomSettings) (string, erro
|
||||
|
||||
// Creating the actual container
|
||||
container, err := manager.client.ContainerCreate(
|
||||
context.Background(),
|
||||
ctx,
|
||||
config,
|
||||
hostConfig,
|
||||
networkingConfig,
|
||||
@@ -640,8 +640,8 @@ func (manager *RoomManagerCtx) Create(settings types.RoomSettings) (string, erro
|
||||
return container.ID[:12], nil
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) GetEntry(id string) (*types.RoomEntry, error) {
|
||||
container, err := manager.containerById(id)
|
||||
func (manager *RoomManagerCtx) GetEntry(ctx context.Context, id string) (*types.RoomEntry, error) {
|
||||
container, err := manager.containerById(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -649,8 +649,8 @@ func (manager *RoomManagerCtx) GetEntry(id string) (*types.RoomEntry, error) {
|
||||
return manager.containerToEntry(*container)
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) GetEntryByName(name string) (*types.RoomEntry, error) {
|
||||
container, err := manager.containerByName(name)
|
||||
func (manager *RoomManagerCtx) GetEntryByName(ctx context.Context, name string) (*types.RoomEntry, error) {
|
||||
container, err := manager.containerByName(ctx, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -658,21 +658,21 @@ func (manager *RoomManagerCtx) GetEntryByName(name string) (*types.RoomEntry, er
|
||||
return manager.containerToEntry(*container)
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) Remove(id string) error {
|
||||
_, err := manager.inspectContainer(id)
|
||||
func (manager *RoomManagerCtx) Remove(ctx context.Context, id string) error {
|
||||
_, err := manager.inspectContainer(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Stop the actual container
|
||||
err = manager.client.ContainerStop(context.Background(), id, container.StopOptions{})
|
||||
err = manager.client.ContainerStop(ctx, id, container.StopOptions{})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Remove the actual container
|
||||
err = manager.client.ContainerRemove(context.Background(), id, dockerTypes.ContainerRemoveOptions{
|
||||
err = manager.client.ContainerRemove(ctx, id, dockerTypes.ContainerRemoveOptions{
|
||||
RemoveVolumes: true,
|
||||
Force: true,
|
||||
})
|
||||
@@ -680,8 +680,8 @@ func (manager *RoomManagerCtx) Remove(id string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) GetSettings(id string) (*types.RoomSettings, error) {
|
||||
container, err := manager.inspectContainer(id)
|
||||
func (manager *RoomManagerCtx) GetSettings(ctx context.Context, id string) (*types.RoomSettings, error) {
|
||||
container, err := manager.inspectContainer(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -824,8 +824,8 @@ func (manager *RoomManagerCtx) GetSettings(id string) (*types.RoomSettings, erro
|
||||
return &settings, err
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) GetStats(id string) (*types.RoomStats, error) {
|
||||
container, err := manager.inspectContainer(id)
|
||||
func (manager *RoomManagerCtx) GetStats(ctx context.Context, id string) (*types.RoomStats, error) {
|
||||
container, err := manager.inspectContainer(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -836,7 +836,7 @@ func (manager *RoomManagerCtx) GetStats(id string) (*types.RoomStats, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
output, err := manager.containerExec(id, []string{
|
||||
output, err := manager.containerExec(ctx, id, []string{
|
||||
"wget", "-q", "-O-", "http://127.0.0.1:8080/stats?pwd=" + url.QueryEscape(settings.AdminPass),
|
||||
})
|
||||
if err != nil {
|
||||
@@ -851,32 +851,32 @@ func (manager *RoomManagerCtx) GetStats(id string) (*types.RoomStats, error) {
|
||||
return &stats, nil
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) Start(id string) error {
|
||||
_, err := manager.inspectContainer(id)
|
||||
func (manager *RoomManagerCtx) Start(ctx context.Context, id string) error {
|
||||
_, err := manager.inspectContainer(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Start the actual container
|
||||
return manager.client.ContainerStart(context.Background(), id, dockerTypes.ContainerStartOptions{})
|
||||
return manager.client.ContainerStart(ctx, id, dockerTypes.ContainerStartOptions{})
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) Stop(id string) error {
|
||||
_, err := manager.inspectContainer(id)
|
||||
func (manager *RoomManagerCtx) Stop(ctx context.Context, id string) error {
|
||||
_, err := manager.inspectContainer(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Stop the actual container
|
||||
return manager.client.ContainerStop(context.Background(), id, container.StopOptions{})
|
||||
return manager.client.ContainerStop(ctx, id, container.StopOptions{})
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) Restart(id string) error {
|
||||
_, err := manager.inspectContainer(id)
|
||||
func (manager *RoomManagerCtx) Restart(ctx context.Context, id string) error {
|
||||
_, err := manager.inspectContainer(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Restart the actual container
|
||||
return manager.client.ContainerRestart(context.Background(), id, container.StopOptions{})
|
||||
return manager.client.ContainerRestart(ctx, id, container.StopOptions{})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package room
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"sort"
|
||||
)
|
||||
@@ -10,7 +11,7 @@ type EprPorts struct {
|
||||
Max uint16
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) allocatePorts(sum uint16) (EprPorts, error) {
|
||||
func (manager *RoomManagerCtx) allocatePorts(ctx context.Context, sum uint16) (EprPorts, error) {
|
||||
if sum < 1 {
|
||||
return EprPorts{}, fmt.Errorf("unable to allocate 0 ports")
|
||||
}
|
||||
@@ -23,7 +24,7 @@ func (manager *RoomManagerCtx) allocatePorts(sum uint16) (EprPorts, error) {
|
||||
Max: min + sum - 1,
|
||||
}
|
||||
|
||||
ports, err := manager.getUsedPorts()
|
||||
ports, err := manager.getUsedPorts(ctx)
|
||||
if err != nil {
|
||||
return epr, err
|
||||
}
|
||||
@@ -43,8 +44,8 @@ func (manager *RoomManagerCtx) allocatePorts(sum uint16) (EprPorts, error) {
|
||||
return epr, nil
|
||||
}
|
||||
|
||||
func (manager *RoomManagerCtx) getUsedPorts() ([]EprPorts, error) {
|
||||
containers, err := manager.listContainers(nil)
|
||||
func (manager *RoomManagerCtx) getUsedPorts(ctx context.Context) ([]EprPorts, error) {
|
||||
containers, err := manager.listContainers(ctx, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
+12
-11
@@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -287,17 +288,17 @@ var ErrRoomNotFound = fmt.Errorf("room not found")
|
||||
|
||||
type RoomManager interface {
|
||||
Config() RoomsConfig
|
||||
List(labels map[string]string) ([]RoomEntry, error)
|
||||
ExportAsDockerCompose() ([]byte, error)
|
||||
List(ctx context.Context, labels map[string]string) ([]RoomEntry, error)
|
||||
ExportAsDockerCompose(ctx context.Context) ([]byte, error)
|
||||
|
||||
Create(settings RoomSettings) (string, error)
|
||||
GetEntry(id string) (*RoomEntry, error)
|
||||
GetEntryByName(name string) (*RoomEntry, error)
|
||||
GetSettings(id string) (*RoomSettings, error)
|
||||
GetStats(id string) (*RoomStats, error)
|
||||
Remove(id string) error
|
||||
Create(ctx context.Context, settings RoomSettings) (string, error)
|
||||
GetEntry(ctx context.Context, id string) (*RoomEntry, error)
|
||||
GetEntryByName(ctx context.Context, name string) (*RoomEntry, error)
|
||||
GetSettings(ctx context.Context, id string) (*RoomSettings, error)
|
||||
GetStats(ctx context.Context, id string) (*RoomStats, error)
|
||||
Remove(ctx context.Context, id string) error
|
||||
|
||||
Start(id string) error
|
||||
Stop(id string) error
|
||||
Restart(id string) error
|
||||
Start(ctx context.Context, id string) error
|
||||
Stop(ctx context.Context, id string) error
|
||||
Restart(ctx context.Context, id string) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user