Resolver represents logic, such as a SQL query, that produces output data. Resolvers are used to evaluate API requests, alerts, reports, etc. A resolver has two levels of configuration: static properties and dynamic arguments. For example, a SQL resolver has a static property for the SQL query and
| 38 | // For example, a SQL resolver has a static property for the SQL query and dynamic arguments for the query parameters. |
| 39 | // The static properties are usually declared in advance, such as in the YAML for a custom API, whereas the dynamic arguments are provided just prior to execution, such as in an API request. |
| 40 | type Resolver interface { |
| 41 | // Close is called when done with the resolver. |
| 42 | // Note that the Resolve method may not have been called when Close is called (in case of cache hits or validation failures). |
| 43 | Close() error |
| 44 | // CacheKey returns a key that can be used for caching. It can be a large string since the value will be hashed. |
| 45 | // The key should include all the properties and args that affect the output. |
| 46 | // It does not need to include the instance ID or resolver name, as those are added separately to the cache key. |
| 47 | // |
| 48 | // If the resolver result is not cacheable, ok is set to false. |
| 49 | CacheKey(ctx context.Context) (key []byte, ok bool, err error) |
| 50 | // Refs access by the resolver. The output may be approximate, i.e. some of the refs may not exist. |
| 51 | // The output should avoid duplicates and be stable between invocations. |
| 52 | // This is also used while resolving transitive access rules, resources retuned by Refs() will be given access. |
| 53 | Refs() []*runtimev1.ResourceName |
| 54 | // Validate the properties and args without running any expensive operations. |
| 55 | Validate(ctx context.Context) error |
| 56 | // ResolveInteractive resolves data for interactive use (e.g. API requests or alerts). |
| 57 | ResolveInteractive(ctx context.Context) (ResolverResult, error) |
| 58 | // ResolveExport resolve data for export (e.g. downloads or reports). |
| 59 | ResolveExport(ctx context.Context, w io.Writer, opts *ResolverExportOptions) error |
| 60 | // InferRequiredSecurityRules attempts to infer the security rules that are required to be able to execute the resolver for the currently configured properties. |
| 61 | InferRequiredSecurityRules() ([]*runtimev1.SecurityRule, error) |
| 62 | } |
| 63 | |
| 64 | // ResolverResult is the result of a resolver's execution. |
| 65 | type ResolverResult interface { |
no outgoing calls
no test coverage detected