MCPcopy
hub / github.com/livekit/livekit / NewLocalNode

Function NewLocalNode

pkg/routing/node.go:49–76  ·  view source on GitHub ↗
(conf *config.Config)

Source from the content-addressed store, hash-verified

47}
48
49func NewLocalNode(conf *config.Config) (*LocalNodeImpl, error) {
50 nodeID := guid.New(utils.NodePrefix)
51 if conf != nil && conf.RTC.NodeIP.IsEmpty() {
52 return nil, ErrIPNotSet
53 }
54 nowUnix := time.Now().Unix()
55 l := &LocalNodeImpl{
56 node: &livekit.Node{
57 Id: nodeID,
58 NumCpus: uint32(runtime.NumCPU()),
59 State: livekit.NodeState_SERVING,
60 Stats: &livekit.NodeStats{
61 StartedAt: nowUnix,
62 UpdatedAt: nowUnix,
63 },
64 },
65 }
66 var nsc *config.NodeStatsConfig
67 if conf != nil {
68 l.node.Ip = conf.RTC.NodeIP.PrimaryIP()
69 l.node.Region = conf.Region
70
71 nsc = &conf.NodeStats
72 }
73 l.nodeStats = NewNodeStats(nsc, nowUnix)
74
75 return l, nil
76}
77
78func NewLocalNodeFromNodeProto(node *livekit.Node) (*LocalNodeImpl, error) {
79 return &LocalNodeImpl{node: utils.CloneProto(node)}, nil

Callers 8

TestCreateRoomFunction · 0.92
SelectRoomNodeFunction · 0.92
NewTestServerFunction · 0.92
createSingleNodeServerFunction · 0.92
createMultiNodeServerFunction · 0.92
setupServerWithWebhookFunction · 0.92
listNodesFunction · 0.92
startServerFunction · 0.92

Calls 1

NewNodeStatsFunction · 0.85

Tested by 3

TestCreateRoomFunction · 0.74
SelectRoomNodeFunction · 0.74
setupServerWithWebhookFunction · 0.74