(streamPath string, url string, pusher IPusher, save bool)
| 324 | var Pushers sync.Map |
| 325 | |
| 326 | func (opt *Plugin) Push(streamPath string, url string, pusher IPusher, save bool) (err error) { |
| 327 | zp, zu := zap.String("stream", streamPath), zap.String("url", url) |
| 328 | opt.Info("push", zp, zu) |
| 329 | defer func() { |
| 330 | if err != nil { |
| 331 | opt.Error("push faild", zap.Error(err)) |
| 332 | } |
| 333 | }() |
| 334 | conf, ok := opt.Config.(config.PushConfig) |
| 335 | if !ok { |
| 336 | return ErrNoPushConfig |
| 337 | } |
| 338 | pushConfig := conf.GetPushConfig() |
| 339 | pusher.init(streamPath, url, pushConfig) |
| 340 | pusher.SetLogger(opt.Logger.With(zp, zu)) |
| 341 | opt.AssignSubConfig(pusher.GetSubscriber()) |
| 342 | go pusher.startPush(pusher) |
| 343 | if save { |
| 344 | pushConfig.AddPush(url, streamPath) |
| 345 | opt.RawConfig.Get("push").Get("pushlist").Modify = pushConfig.PushList |
| 346 | if err = opt.Save(); err != nil { |
| 347 | opt.Error("save faild", zap.Error(err)) |
| 348 | } |
| 349 | } |
| 350 | return |
| 351 | } |
nothing calls this directly
no test coverage detected