-
Notifications
You must be signed in to change notification settings - Fork 47
/
actioner.go
39 lines (28 loc) · 949 Bytes
/
actioner.go
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
/*
Copyright (c) 2021 - Present. Blend Labs, Inc. All rights reserved
Use of this source code is governed by a MIT license that can be found in the LICENSE file.
*/
package async
import "context"
// Actioner is a type that can be used as a tracked action.
type Actioner interface {
Action(context.Context, interface{}) (interface{}, error)
}
var (
_ Actioner = (*ActionerFunc)(nil)
)
// ActionerFunc is a function that implements action.
type ActionerFunc func(context.Context, interface{}) (interface{}, error)
// Action implements actioner for the function.
func (af ActionerFunc) Action(ctx context.Context, args interface{}) (interface{}, error) {
return af(ctx, args)
}
var (
_ Actioner = (*NoopActioner)(nil)
)
// NoopActioner is an actioner type that does nothing.
type NoopActioner struct{}
// Action implements actioner
func (n NoopActioner) Action(_ context.Context, _ interface{}) (interface{}, error) {
return nil, nil
}