mirror of
https://github.com/m1k1o/neko-rooms.git
synced 2026-11-02 22:51:34 -06:00
container labels and room event type.
This commit is contained in:
@@ -34,6 +34,8 @@ func (manager *RoomManagerCtx) containerToEntry(container dockerTypes.Container)
|
|||||||
Status: container.Status,
|
Status: container.Status,
|
||||||
Created: time.Unix(container.Created, 0),
|
Created: time.Unix(container.Created, 0),
|
||||||
Labels: labels.UserDefined,
|
Labels: labels.UserDefined,
|
||||||
|
|
||||||
|
ContainerLabels: container.Labels,
|
||||||
}
|
}
|
||||||
|
|
||||||
if labels.Mux {
|
if labels.Mux {
|
||||||
|
|||||||
+11
-9
@@ -93,8 +93,9 @@ func (e *events) Start() {
|
|||||||
|
|
||||||
e.broadcast(types.RoomEvent{
|
e.broadcast(types.RoomEvent{
|
||||||
ID: room.id,
|
ID: room.id,
|
||||||
Action: "ready",
|
Action: types.RoomEventReady,
|
||||||
Labels: room.labels,
|
|
||||||
|
ContainerLabels: room.labels,
|
||||||
})
|
})
|
||||||
case msg := <-msgs:
|
case msg := <-msgs:
|
||||||
roomId := msg.Actor.ID[:12]
|
roomId := msg.Actor.ID[:12]
|
||||||
@@ -105,30 +106,31 @@ func (e *events) Start() {
|
|||||||
Str("action", msg.Action).
|
Str("action", msg.Action).
|
||||||
Msg("got docker event")
|
Msg("got docker event")
|
||||||
|
|
||||||
action := ""
|
var action types.RoomEventAction
|
||||||
switch msg.Action {
|
switch msg.Action {
|
||||||
case "create":
|
case "create":
|
||||||
action = "created"
|
action = types.RoomEventCreated
|
||||||
case "start":
|
case "start":
|
||||||
action = "started"
|
action = types.RoomEventStarted
|
||||||
e.waitForRoomReady(roomId, labels)
|
e.waitForRoomReady(roomId, labels)
|
||||||
case "health_status: healthy":
|
case "health_status: healthy":
|
||||||
action = "ready"
|
action = types.RoomEventReady
|
||||||
// ignore if room was already ready
|
// ignore if room was already ready
|
||||||
if !e.setRoomReady(roomId) {
|
if !e.setRoomReady(roomId) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
case "stop":
|
case "stop":
|
||||||
action = "stopped"
|
action = types.RoomEventStopped
|
||||||
e.setRoomNotReady(roomId)
|
e.setRoomNotReady(roomId)
|
||||||
case "destroy":
|
case "destroy":
|
||||||
action = "destroyed"
|
action = types.RoomEventDestroyed
|
||||||
}
|
}
|
||||||
|
|
||||||
e.broadcast(types.RoomEvent{
|
e.broadcast(types.RoomEvent{
|
||||||
ID: roomId,
|
ID: roomId,
|
||||||
Action: action,
|
Action: action,
|
||||||
Labels: labels,
|
|
||||||
|
ContainerLabels: labels,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-3
@@ -27,6 +27,8 @@ type RoomEntry struct {
|
|||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
Labels map[string]string `json:"labels,omitempty"`
|
Labels map[string]string `json:"labels,omitempty"`
|
||||||
|
|
||||||
|
ContainerLabels map[string]string `json:"-"` // for internal use
|
||||||
}
|
}
|
||||||
|
|
||||||
type MountType string
|
type MountType string
|
||||||
@@ -139,10 +141,21 @@ type RoomMember struct {
|
|||||||
Muted bool `json:"muted"`
|
Muted bool `json:"muted"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type RoomEventAction string
|
||||||
|
|
||||||
|
const (
|
||||||
|
RoomEventCreated RoomEventAction = "created"
|
||||||
|
RoomEventStarted RoomEventAction = "started"
|
||||||
|
RoomEventReady RoomEventAction = "ready"
|
||||||
|
RoomEventStopped RoomEventAction = "stopped"
|
||||||
|
RoomEventDestroyed RoomEventAction = "destroyed"
|
||||||
|
)
|
||||||
|
|
||||||
type RoomEvent struct {
|
type RoomEvent struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Action string `json:"action"`
|
Action RoomEventAction `json:"action"`
|
||||||
Labels map[string]string `json:"-"`
|
|
||||||
|
ContainerLabels map[string]string `json:"-"` // for internal use
|
||||||
}
|
}
|
||||||
|
|
||||||
var ErrRoomNotFound = fmt.Errorf("room not found")
|
var ErrRoomNotFound = fmt.Errorf("room not found")
|
||||||
|
|||||||
Reference in New Issue
Block a user