1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 // Package api provides types used by controller/server-component
11 // A RoutableFunc calls an API method (sometimes via a wrapped
12 // RoutableFunc) that has real argument types.
14 // (It is used by ctrlctx to manage database transactions, so moving
15 // it to the router package would cause a circular dependency
16 // router->arvadostest->ctrlctx->router.)
17 type RoutableFunc func(ctx context.Context, opts interface{}) (interface{}, error)
19 type RoutableFuncWrapper func(RoutableFunc) RoutableFunc
21 // ComposeWrappers (w1, w2, w3, ...) returns a RoutableFuncWrapper that
22 // composes w1, w2, w3, ... such that w1 is the outermost wrapper.
23 func ComposeWrappers(wraps ...RoutableFuncWrapper) RoutableFuncWrapper {
24 return func(f RoutableFunc) RoutableFunc {
25 for i := len(wraps) - 1; i >= 0; i-- {