|
|
|
|
@ -24,12 +24,13 @@ func init() { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type RenderingService struct { |
|
|
|
|
log log.Logger |
|
|
|
|
pluginClient *plugin.Client |
|
|
|
|
grpcPlugin pluginModel.RendererPlugin |
|
|
|
|
pluginInfo *plugins.RendererPlugin |
|
|
|
|
renderAction renderFunc |
|
|
|
|
domain string |
|
|
|
|
log log.Logger |
|
|
|
|
pluginClient *plugin.Client |
|
|
|
|
grpcPlugin pluginModel.RendererPlugin |
|
|
|
|
pluginInfo *plugins.RendererPlugin |
|
|
|
|
renderAction renderFunc |
|
|
|
|
domain string |
|
|
|
|
inProgressCount int |
|
|
|
|
|
|
|
|
|
Cfg *setting.Cfg `inject:""` |
|
|
|
|
} |
|
|
|
|
@ -89,7 +90,27 @@ func (rs *RenderingService) Run(ctx context.Context) error { |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (rs *RenderingService) getLimit(isAlerting bool) int { |
|
|
|
|
if isAlerting { |
|
|
|
|
return rs.Cfg.RendererLimitAlerting |
|
|
|
|
} else { |
|
|
|
|
return rs.Cfg.RendererLimit |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
func (rs *RenderingService) Render(ctx context.Context, opts Opts) (*RenderResult, error) { |
|
|
|
|
if rs.inProgressCount > rs.getLimit(opts.IsAlert) { |
|
|
|
|
return &RenderResult{ |
|
|
|
|
FilePath: filepath.Join(setting.HomePath, "public/img/rendering_limit.png"), |
|
|
|
|
}, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
defer func() { |
|
|
|
|
rs.inProgressCount -= 1 |
|
|
|
|
}() |
|
|
|
|
|
|
|
|
|
rs.inProgressCount += 1 |
|
|
|
|
|
|
|
|
|
if rs.renderAction != nil { |
|
|
|
|
return rs.renderAction(ctx, opts) |
|
|
|
|
} else { |
|
|
|
|
|