Reorder API struct fields for better alignment

This commit is contained in:
sergystepanov 2026-07-03 19:22:50 +03:00
parent 9d72022b57
commit 0edba391f2
3 changed files with 12 additions and 12 deletions

View file

@ -41,8 +41,8 @@ type (
type In[I Id] struct {
Id I `json:"id,omitempty"`
T PT `json:"t"`
Payload json.RawMessage `json:"p,omitempty"` // should be json.RawMessage for 2-pass unmarshal
T PT `json:"t"`
}
func (i In[I]) GetId() I { return i.Id }
@ -50,9 +50,9 @@ func (i In[I]) GetPayload() []byte { return i.Payload }
func (i In[I]) GetType() PT { return i.T }
type Out struct {
Payload any `json:"p,omitempty"`
Id string `json:"id,omitempty"` // string because omitempty won't work as intended with arrays
T uint8 `json:"t"`
Payload any `json:"p,omitempty"`
}
func (o *Out) SetId(s string) { o.Id = s }

View file

@ -3,13 +3,13 @@ package api
type (
CloseRoomRequest string
ConnectionRequest[T Id] struct {
Addr string `json:"addr,omitempty"`
Id T `json:"id,omitempty"`
IsHTTPS bool `json:"is_https,omitempty"`
Addr string `json:"addr,omitempty"`
PingURL string `json:"ping_url,omitempty"`
Port string `json:"port,omitempty"`
Tag string `json:"tag,omitempty"`
Zone string `json:"zone,omitempty"`
IsHTTPS bool `json:"is_https,omitempty"`
}
GetWorkerListResponse struct {
Servers []Server `json:"servers"`
@ -28,15 +28,15 @@ const (
// Server is a separate machine that may contain
// multiple sub-processes.
type Server struct {
Addr string `json:"addr,omitempty"`
Id Id `json:"id,omitempty"`
IsBusy bool `json:"is_busy,omitempty"`
InGroup bool `json:"in_group,omitempty"`
Addr string `json:"addr,omitempty"`
Machine string `json:"machine,omitempty"`
PingURL string `json:"ping_url"`
Port string `json:"port,omitempty"`
Replicas uint32 `json:"replicas,omitempty"`
Room string `json:"room,omitempty"`
Tag string `json:"tag,omitempty"`
Zone string `json:"zone,omitempty"`
Replicas uint32 `json:"replicas,omitempty"`
IsBusy bool `json:"is_busy,omitempty"`
InGroup bool `json:"in_group,omitempty"`
}

View file

@ -7,13 +7,13 @@ type (
GameStartUserRequest struct {
GameName string `json:"game_name"`
RoomId string `json:"room_id"`
Record bool `json:"record,omitempty"`
RecordUser string `json:"record_user,omitempty"`
PlayerIndex int `json:"player_index"`
Record bool `json:"record,omitempty"`
}
GameStartUserResponse struct {
RoomId string `json:"roomId"`
Av *AppVideoInfo `json:"av"`
RoomId string `json:"roomId"`
KbMouse bool `json:"kb_mouse"`
}
IceServer struct {
@ -22,9 +22,9 @@ type (
Credential string `json:"credential,omitempty"`
}
InitSessionUserResponse struct {
Wid string `json:"wid"`
Ice []IceServer `json:"ice"`
Games []AppMeta `json:"games"`
Wid string `json:"wid"`
}
AppMeta struct {
Alias string `json:"alias,omitempty"`
@ -36,7 +36,7 @@ type (
Sdp *string `json:"sdp,omitempty"`
}
InitUserWebrtcStreamRequest struct {
Initiator bool `json:"initiator"`
Sdp string `json:"sdp,omitempty"`
Initiator bool `json:"initiator"`
}
)