Atlas › Test

TestNewHandleFailureConditions

Exact test identity: go.temporal.io/server/common/nexus/nexusrpc/TestNewHandleFailureConditions

Package
go.temporal.io/server/common/nexus/nexusrpc
Suite / test hierarchy
TestNewHandleFailureConditions
Test
TestNewHandleFailureConditions
Introduced at
client.go ×3 Frontier kind: Joint frontier
Covered ranges
16
Covered lines
40
Covered files
2

Covered source

Expand a file to inspect source; the > gutter marks covered lines.

go.temporal.io/server/common/nexus/nexusrpc/client.go 37 covered LOC · 15 ranges

Open complete file

152 // NewHTTPClient creates a new [HTTPClient] from provided [HTTPClientOptions].
153 // BaseURL and Service are required.
154 > func NewHTTPClient(options HTTPClientOptions) (*HTTPClient, error) { client.go
155 > if options.HTTPCaller == nil {
156 > options.HTTPCaller = http.DefaultClient.Do
157 > }
158 > if options.BaseURL == "" {
159 return nil, errors.New("empty BaseURL")
160 }
161 > if options.Service == "" { client.go
162 return nil, errors.New("empty Service")
163 }
164 > var baseURL *url.URL client.go
165 > var err error
166 > baseURL, err = url.Parse(options.BaseURL)
167 > if err != nil {
168 return nil, err
169 }
170 > if baseURL.Scheme != "http" && baseURL.Scheme != "https" { client.go
171 return nil, fmt.Errorf("invalid URL scheme: %s", baseURL.Scheme)
172 }
173 > if options.Serializer == nil { client.go
174 > options.Serializer = nexus.DefaultSerializer() client.go
175 > }
176 > if options.FailureConverter == nil { client.go
177 > options.FailureConverter = DefaultFailureConverter() client.go
178 > }
179 > return &HTTPClient{ client.go
180 > baseHTTPClient: baseHTTPClient{
181 > serializer: options.Serializer,
182 > failureConverter: options.FailureConverter,
183 > httpCaller: options.HTTPCaller,
184 > },
185 > serviceBaseURL: baseURL,
186 > service: options.Service,
187 > }, nil
188 }
189
381 // Does not incur a trip to the server.
382 // Fails if provided an empty operation or token.
383 > func (c *HTTPClient) NewOperationHandle(operation string, token string) (*OperationHandle[*nexus.LazyValue], error) { client.go
384 > var es []error
385 > if operation == "" {
386 > es = append(es, errEmptyOperationName) client.go
387 > }
388 > if token == "" { client.go
389 > es = append(es, errEmptyOperationToken) client.go
390 > }
391 > if len(es) > 0 { client.go
392 > return nil, errors.Join(es...) client.go
393 > }
394 return &OperationHandle[*nexus.LazyValue]{
395 client: c,
go.temporal.io/server/common/nexus/nexusrpc/failure_converter.go 3 covered LOC · 1 range

Open complete file

196 // [Failure] instances are converted to [FailureError] to allow access to the full failure metadata and details if
197 // available.
198 > func DefaultFailureConverter() FailureConverter { failure_converter.go
199 > return defaultFailureConverter
200 > }
201
202 func retryBehaviorAsOptionalBool(e *nexus.HandlerError) *bool {