File size: 903 Bytes
d6f631f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
package addondiff

import (
	"github.com/openmeterio/openmeter/openmeter/subscription"
)

// Diffable is a type that can be both applied to a spec and removed from a spec
type Diffable interface {
	// GetApplies returns the applies that will be applied to the spec
	GetApplies() subscription.AppliesToSpec
	// GetRestores returns the restores that will be applied to the spec
	GetRestores() subscription.AppliesToSpec
}

var _ Diffable = &someDiffable{}

type someDiffable struct {
	ApplyFn   func(spec *subscription.SubscriptionSpec, actx subscription.ApplyContext) error
	RestoreFn func(spec *subscription.SubscriptionSpec, actx subscription.ApplyContext) error
}

func (s *someDiffable) GetApplies() subscription.AppliesToSpec {
	return subscription.NewAppliesToSpec(s.ApplyFn)
}

func (s *someDiffable) GetRestores() subscription.AppliesToSpec {
	return subscription.NewAppliesToSpec(s.RestoreFn)
}