(ctx context.Context, auth *coreauth.Auth, req coreexecutor.Request, opts coreexecutor.Options)
| 1716 | } |
| 1717 | |
| 1718 | func (a *executorAdapter) CountTokens(ctx context.Context, auth *coreauth.Auth, req coreexecutor.Request, opts coreexecutor.Options) (resp coreexecutor.Response, err error) { |
| 1719 | if a == nil || a.executor == nil || a.host.isPluginFused(a.pluginID) || !a.host.pluginIdentityCurrent(a.pluginID, a.path, a.version) { |
| 1720 | return coreexecutor.Response{}, fmt.Errorf("plugin executor %s is unavailable", a.Identifier()) |
| 1721 | } |
| 1722 | defer func() { |
| 1723 | if recovered := recover(); recovered != nil { |
| 1724 | a.host.fusePlugin(a.pluginID, "Executor.CountTokens", recovered) |
| 1725 | resp = coreexecutor.Response{} |
| 1726 | err = fmt.Errorf("plugin executor %s count tokens panic: %v", a.Identifier(), recovered) |
| 1727 | } |
| 1728 | }() |
| 1729 | |
| 1730 | prepared, errPrepare := a.prepareExecutorCall(req, opts) |
| 1731 | if errPrepare != nil { |
| 1732 | return coreexecutor.Response{}, errPrepare |
| 1733 | } |
| 1734 | pluginResp, errCountTokens := a.executor.CountTokens(ctx, buildExecutorRequest(a.host, a.provider, auth, prepared.req, prepared.opts)) |
| 1735 | if errCountTokens != nil { |
| 1736 | return coreexecutor.Response{}, errCountTokens |
| 1737 | } |
| 1738 | return coreexecutor.Response{ |
| 1739 | Payload: a.translateExecutorResponse(ctx, prepared, pluginResp.Payload, false, nil), |
| 1740 | Metadata: cloneAnyMap(pluginResp.Metadata), |
| 1741 | Headers: cloneHeader(pluginResp.Headers), |
| 1742 | }, nil |
| 1743 | } |
| 1744 | |
| 1745 | func (a *executorAdapter) HttpRequest(ctx context.Context, auth *coreauth.Auth, req *http.Request) (resp *http.Response, err error) { |
| 1746 | if a == nil || a.executor == nil || a.host.isPluginFused(a.pluginID) || !a.host.pluginIdentityCurrent(a.pluginID, a.path, a.version) { |
nothing calls this directly
no test coverage detected