MCPcopy
hub / github.com/larksuite/cli / cachedLarkClientFunc

Function cachedLarkClientFunc

internal/cmdutil/factory_default.go:131–153  ·  view source on GitHub ↗
(f *Factory)

Source from the content-addressed store, hash-verified

129}
130
131func cachedLarkClientFunc(f *Factory) func() (*lark.Client, error) {
132 return sync.OnceValues(func() (*lark.Client, error) {
133 acct, err := f.Credential.ResolveAccount(context.Background())
134 if err != nil {
135 return nil, err
136 }
137 opts := []lark.ClientOptionFunc{
138 lark.WithEnableTokenCache(false),
139 lark.WithLogLevel(larkcore.LogLevelError),
140 lark.WithHeaders(BaseSecurityHeaders()),
141 }
142 if f.IOStreams.StderrIsTerminal {
143 warnIfProxied(f.IOStreams.ErrOut)
144 }
145 opts = append(opts, lark.WithHttpClient(&http.Client{
146 Transport: buildSDKTransport(),
147 CheckRedirect: safeRedirectPolicy,
148 }))
149 ep := core.ResolveEndpoints(acct.Brand)
150 opts = append(opts, lark.WithOpenBaseUrl(ep.Open))
151 return lark.NewClient(acct.AppID, credential.RuntimeAppSecret(acct.AppSecret), opts...), nil
152 })
153}
154
155func buildSDKTransport() http.RoundTripper {
156 var sdkTransport http.RoundTripper = transport.Shared()

Callers 2

NewDefaultFunction · 0.85

Calls 5

ResolveEndpointsFunction · 0.92
RuntimeAppSecretFunction · 0.92
BaseSecurityHeadersFunction · 0.85
buildSDKTransportFunction · 0.85
ResolveAccountMethod · 0.65

Tested by 1