-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathservice_disabled.go
More file actions
46 lines (35 loc) · 1.65 KB
/
Copy pathservice_disabled.go
File metadata and controls
46 lines (35 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// SPDX-License-Identifier: AGPL-3.0-or-later
//go:build no_webhook
// +build no_webhook
// Stub — provides a no-op Service when this plugin is disabled at
// build time via -tags=no_webhook. The daemon registers the no-op so
// plugin start/stop are clean; no bus subscription is created and
// no HTTP delivery happens.
package webhook
import (
"context"
"github.com/pilot-protocol/common/coreapi"
)
// Stats mirrors the real Stats so cmd/daemon's webhookManagerAdapter
// (which reads .Dropped and .CircuitSkips) compiles unchanged when
// the plugin is disabled.
type Stats struct {
Dropped uint64
CircuitSkips uint64
}
// Service is a no-op replacement for the real plugin Service.
type Service struct{}
// NewService returns a disabled webhook stub. Same signature as the
// real NewService (variadic Option, defined in webhook.go which stays
// unconditional, so the type is always available).
func NewService(_ string, _ ...Option) *Service { return &Service{} }
func (s *Service) Name() string { return "webhook-disabled" }
func (s *Service) Order() int { return 90 }
func (s *Service) Start(_ context.Context, _ coreapi.Deps) error { return nil }
func (s *Service) Stop(_ context.Context) error { return nil }
// SetURL is a silent no-op when the plugin is disabled. Persisting
// the URL would be misleading because nothing is going to deliver to
// it; callers learn the result via Stats() returning zero counters.
func (s *Service) SetURL(_ string) {}
// Stats always returns the zero value when the plugin is disabled.
func (s *Service) Stats() Stats { return Stats{} }