github.com/blend/go-sdk@v1.20220411.3/async/actioner.go (about)

     1  /*
     2  
     3  Copyright (c) 2022 - Present. Blend Labs, Inc. All rights reserved
     4  Use of this source code is governed by a MIT license that can be found in the LICENSE file.
     5  
     6  */
     7  
     8  package async
     9  
    10  import "context"
    11  
    12  // Actioner is a type that can be used as a tracked action.
    13  type Actioner interface {
    14  	Action(context.Context, interface{}) (interface{}, error)
    15  }
    16  
    17  var (
    18  	_ Actioner = (*ActionerFunc)(nil)
    19  )
    20  
    21  // ActionerFunc is a function that implements action.
    22  type ActionerFunc func(context.Context, interface{}) (interface{}, error)
    23  
    24  // Action implements actioner for the function.
    25  func (af ActionerFunc) Action(ctx context.Context, args interface{}) (interface{}, error) {
    26  	return af(ctx, args)
    27  }
    28  
    29  var (
    30  	_ Actioner = (*NoopActioner)(nil)
    31  )
    32  
    33  // NoopActioner is an actioner type that does nothing.
    34  type NoopActioner struct{}
    35  
    36  // Action implements actioner
    37  func (n NoopActioner) Action(_ context.Context, _ interface{}) (interface{}, error) {
    38  	return nil, nil
    39  }