mirror of
https://github.com/datarhei/core.git
synced 2025-10-05 16:07:07 +08:00
Add cluster endpoint for listing the nodes
This commit is contained in:
64
docs/docs.go
64
docs/docs.go
@@ -209,6 +209,38 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v3/cluster": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "List of nodes in the cluster",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"summary": "List of nodes in the cluster",
|
||||
"operationId": "cluster-3-get-cluster",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.ClusterNode"
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v3/cluster/node": {
|
||||
"post": {
|
||||
"security": [
|
||||
@@ -2142,7 +2174,10 @@ const docTemplate = `{
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.SRTChannels"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.SRTChannel"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2509,6 +2544,12 @@ const docTemplate = `{
|
||||
"address": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_update": {
|
||||
"type": "integer"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -3755,7 +3796,7 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"api.SRTChannels": {
|
||||
"api.SRTChannel": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"connections": {
|
||||
@@ -3773,19 +3814,16 @@ const docTemplate = `{
|
||||
}
|
||||
}
|
||||
},
|
||||
"publisher": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer"
|
||||
}
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"socketid": {
|
||||
"type": "integer"
|
||||
},
|
||||
"subscriber": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -201,6 +201,38 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v3/cluster": {
|
||||
"get": {
|
||||
"security": [
|
||||
{
|
||||
"ApiKeyAuth": []
|
||||
}
|
||||
],
|
||||
"description": "List of nodes in the cluster",
|
||||
"produces": [
|
||||
"application/json"
|
||||
],
|
||||
"summary": "List of nodes in the cluster",
|
||||
"operationId": "cluster-3-get-cluster",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "OK",
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.ClusterNode"
|
||||
}
|
||||
}
|
||||
},
|
||||
"404": {
|
||||
"description": "Not Found",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/api.Error"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"/api/v3/cluster/node": {
|
||||
"post": {
|
||||
"security": [
|
||||
@@ -2134,7 +2166,10 @@
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.SRTChannels"
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/api.SRTChannel"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2501,6 +2536,12 @@
|
||||
"address": {
|
||||
"type": "string"
|
||||
},
|
||||
"id": {
|
||||
"type": "string"
|
||||
},
|
||||
"last_update": {
|
||||
"type": "integer"
|
||||
},
|
||||
"state": {
|
||||
"type": "string"
|
||||
}
|
||||
@@ -3747,7 +3788,7 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"api.SRTChannels": {
|
||||
"api.SRTChannel": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"connections": {
|
||||
@@ -3765,19 +3806,16 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"publisher": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "integer"
|
||||
}
|
||||
"name": {
|
||||
"type": "string"
|
||||
},
|
||||
"socketid": {
|
||||
"type": "integer"
|
||||
},
|
||||
"subscriber": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -60,6 +60,10 @@ definitions:
|
||||
properties:
|
||||
address:
|
||||
type: string
|
||||
id:
|
||||
type: string
|
||||
last_update:
|
||||
type: integer
|
||||
state:
|
||||
type: string
|
||||
type: object
|
||||
@@ -879,7 +883,7 @@ definitions:
|
||||
name:
|
||||
type: string
|
||||
type: object
|
||||
api.SRTChannels:
|
||||
api.SRTChannel:
|
||||
properties:
|
||||
connections:
|
||||
additionalProperties:
|
||||
@@ -891,16 +895,14 @@ definitions:
|
||||
$ref: '#/definitions/api.SRTLog'
|
||||
type: array
|
||||
type: object
|
||||
publisher:
|
||||
additionalProperties:
|
||||
type: integer
|
||||
type: object
|
||||
name:
|
||||
type: string
|
||||
socketid:
|
||||
type: integer
|
||||
subscriber:
|
||||
additionalProperties:
|
||||
items:
|
||||
type: integer
|
||||
type: array
|
||||
type: object
|
||||
items:
|
||||
type: integer
|
||||
type: array
|
||||
type: object
|
||||
api.SRTConnection:
|
||||
properties:
|
||||
@@ -1867,6 +1869,26 @@ paths:
|
||||
schema:
|
||||
type: string
|
||||
summary: Swagger UI for this API
|
||||
/api/v3/cluster:
|
||||
get:
|
||||
description: List of nodes in the cluster
|
||||
operationId: cluster-3-get-cluster
|
||||
produces:
|
||||
- application/json
|
||||
responses:
|
||||
"200":
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/api.ClusterNode'
|
||||
type: array
|
||||
"404":
|
||||
description: Not Found
|
||||
schema:
|
||||
$ref: '#/definitions/api.Error'
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
summary: List of nodes in the cluster
|
||||
/api/v3/cluster/node:
|
||||
post:
|
||||
consumes:
|
||||
@@ -3131,7 +3153,9 @@ paths:
|
||||
description: OK
|
||||
schema:
|
||||
items:
|
||||
$ref: '#/definitions/api.SRTChannels'
|
||||
items:
|
||||
$ref: '#/definitions/api.SRTChannel'
|
||||
type: array
|
||||
type: array
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
|
@@ -22,6 +22,35 @@ func NewCluster(cluster cluster.Cluster) *ClusterHandler {
|
||||
}
|
||||
}
|
||||
|
||||
// GetCluster returns the list of nodes in the cluster
|
||||
// @Summary List of nodes in the cluster
|
||||
// @Description List of nodes in the cluster
|
||||
// @ID cluster-3-get-cluster
|
||||
// @Produce json
|
||||
// @Success 200 {array} api.ClusterNode
|
||||
// @Failure 404 {object} api.Error
|
||||
// @Security ApiKeyAuth
|
||||
// @Router /api/v3/cluster [get]
|
||||
func (h *ClusterHandler) GetCluster(c echo.Context) error {
|
||||
nodes := h.cluster.ListNodes()
|
||||
|
||||
list := []api.ClusterNode{}
|
||||
|
||||
for _, node := range nodes {
|
||||
state := node.State()
|
||||
n := api.ClusterNode{
|
||||
Address: node.Address(),
|
||||
ID: state.ID,
|
||||
LastUpdate: state.LastUpdate.Unix(),
|
||||
State: state.State,
|
||||
}
|
||||
|
||||
list = append(list, n)
|
||||
}
|
||||
|
||||
return c.JSON(http.StatusOK, list)
|
||||
}
|
||||
|
||||
// AddNode adds a new node
|
||||
// @Summary Add a new node
|
||||
// @Description Add a new node to the cluster
|
||||
|
@@ -659,6 +659,7 @@ func (s *server) setRoutesV3(v3 *echo.Group) {
|
||||
|
||||
// v3 Cluster
|
||||
if s.v3handler.cluster != nil {
|
||||
v3.GET("/cluster", s.v3handler.cluster.GetCluster)
|
||||
v3.GET("/cluster/node/:id", s.v3handler.cluster.GetNode)
|
||||
v3.GET("/cluster/node/:id/proxy", s.v3handler.cluster.GetNodeProxy)
|
||||
|
||||
|
Reference in New Issue
Block a user