Skip to content

Commit e02d2b5

Browse files
authored
Remove deprecated APIs (#64)
1 parent 54c0ab3 commit e02d2b5

File tree

5 files changed

+4
-107
lines changed

5 files changed

+4
-107
lines changed

nexus/api.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ import (
1313
)
1414

1515
const (
16-
// HeaderOperationID is the unique ID returned by the StartOperation response for async operations.
17-
// Must be set on callback headers to support completing operations before the start response is received.
18-
//
19-
// Deprecated: Use HeaderOperationToken instead.
20-
HeaderOperationID = "nexus-operation-id"
21-
2216
// HeaderOperationToken is the unique token returned by the StartOperation response for async operations.
2317
// Must be set on callback headers to support completing operations before the start response is received.
2418
HeaderOperationToken = "nexus-operation-token"
@@ -64,22 +58,6 @@ type OperationError struct {
6458
Cause error
6559
}
6660

67-
// UnsuccessfulOperationError represents "failed" and "canceled" operation results.
68-
//
69-
// Deprecated: Use [OperationError] instead.
70-
type UnsuccessfulOperationError = OperationError
71-
72-
// NewFailedOperationError is shorthand for constructing an [OperationError] with state set to
73-
// [OperationStateFailed] and the given err as the cause.
74-
//
75-
// Deprecated: Use [NewOperationFailedError] or construct an [OperationError] directly instead.
76-
func NewFailedOperationError(err error) *OperationError {
77-
return &OperationError{
78-
State: OperationStateFailed,
79-
Cause: err,
80-
}
81-
}
82-
8361
// NewOperationFailedError is shorthand for constructing an [OperationError] with state set to
8462
// [OperationStateFailed] and the given error message as the cause.
8563
func NewOperationFailedError(message string) *OperationError {
@@ -98,17 +76,6 @@ func OperationFailedErrorf(format string, args ...any) *OperationError {
9876
}
9977
}
10078

101-
// NewCanceledOperationError is shorthand for constructing an [OperationError] with state set to
102-
// [OperationStateCanceled] and the given err as the cause.
103-
//
104-
// Deprecated: Use [NewOperationCanceledError] or construct an [OperationError] directly instead.
105-
func NewCanceledOperationError(err error) *OperationError {
106-
return &OperationError{
107-
State: OperationStateCanceled,
108-
Cause: err,
109-
}
110-
}
111-
11279
// NewOperationCanceledError is shorthand for constructing an [OperationError] with state set to
11380
// [OperationStateCanceled] and the given error message as the cause.
11481
func NewOperationCanceledError(message string) *OperationError {
@@ -270,10 +237,6 @@ func (e *HandlerError) Unwrap() error {
270237

271238
// OperationInfo conveys information about an operation.
272239
type OperationInfo struct {
273-
// ID of the operation.
274-
//
275-
// Deprecated: Use Token instead.
276-
ID string `json:"id"`
277240
// Token for the operation.
278241
Token string `json:"token"`
279242
// State of the operation.

nexus/handler.go

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,6 @@ type HandlerStartOperationResult[T any] interface {
107107
type HandlerStartOperationResultSync[T any] struct {
108108
// Value is the output of the operation.
109109
Value T
110-
// Links to be associated with the operation.
111-
//
112-
// Deprecated: Use AddHandlerLinks instead.
113-
Links []Link
114110
}
115111

116112
func (*HandlerStartOperationResultSync[T]) mustImplementHandlerStartOperationResult() {}
@@ -122,16 +118,8 @@ func (r *HandlerStartOperationResultSync[T]) ValueAsAny() any {
122118

123119
// HandlerStartOperationResultAsync indicates that an operation has been accepted and will complete asynchronously.
124120
type HandlerStartOperationResultAsync struct {
125-
// OperationID is a unique ID to identify the operation.
126-
//
127-
// Deprecated: Use OperationToken instead.
128-
OperationID string
129121
// OperationToken is a unique token to identify the operation.
130122
OperationToken string
131-
// Links to be associated with the operation.
132-
//
133-
// Deprecated: Use AddHandlerLinks instead.
134-
Links []Link
135123
}
136124

137125
func (*HandlerStartOperationResultAsync) mustImplementHandlerStartOperationResult() {}
@@ -155,20 +143,5 @@ type Handler interface {
155143
// ignored by the underlying operation implemention.
156144
// 2. idempotent - implementors should ignore duplicate cancelations for the same operation.
157145
CancelOperation(ctx context.Context, service, operation, token string, options CancelOperationOptions) error
158-
// GetOperationResult handles requests to get the result of an asynchronous operation. Return non error result
159-
// to respond successfully - inline, or error with [ErrOperationStillRunning] to indicate that an asynchronous
160-
// operation is still running. Return an [OperationError] to indicate that an operation completed as
161-
// failed or canceled.
162-
//
163-
// When [GetOperationResultOptions.Wait] is greater than zero, this request should be treated as a long poll.
164-
// Long poll requests have a server side timeout, configurable via [HandlerOptions.GetResultTimeout], and exposed
165-
// via context deadline. The context deadline is decoupled from the application level Wait duration.
166-
//
167-
// Deprecated: Getting a result directly from a handler is no longer supported.
168-
GetOperationResult(ctx context.Context, service, operation, token string, options GetOperationResultOptions) (any, error)
169-
// GetOperationInfo handles requests to get information about an asynchronous operation.
170-
//
171-
// Deprecated: Getting info directly from a handler is no longer supported.
172-
GetOperationInfo(ctx context.Context, service, operation, token string, options GetOperationInfoOptions) (*OperationInfo, error)
173146
mustEmbedUnimplementedHandler()
174147
}

nexus/operation.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ type OperationHandler[I, O any] interface {
9797
type syncOperation[I, O any] struct {
9898
UnimplementedOperation[I, O]
9999

100-
Handler func(context.Context, I, StartOperationOptions) (O, error)
100+
handler func(context.Context, I, StartOperationOptions) (O, error)
101101
name string
102102
}
103103

104104
// NewSyncOperation is a helper for creating a synchronous-only [Operation] from a given name and handler function.
105-
func NewSyncOperation[I, O any](name string, handler func(context.Context, I, StartOperationOptions) (O, error)) Operation[I, O] {
105+
func NewSyncOperation[I, O any](name string, handler func(ctx context.Context, input I, options StartOperationOptions) (O, error)) Operation[I, O] {
106106
return &syncOperation[I, O]{
107107
name: name,
108-
Handler: handler,
108+
handler: handler,
109109
}
110110
}
111111

@@ -116,7 +116,7 @@ func (h *syncOperation[I, O]) Name() string {
116116

117117
// Start implements Operation.
118118
func (h *syncOperation[I, O]) Start(ctx context.Context, input I, options StartOperationOptions) (HandlerStartOperationResult[O], error) {
119-
o, err := h.Handler(ctx, input, options)
119+
o, err := h.handler(ctx, input, options)
120120
if err != nil {
121121
return nil, err
122122
}

nexus/options.go

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package nexus
22

3-
import "time"
4-
53
// StartOperationOptions are options for the StartOperation client and server APIs.
64
type StartOperationOptions struct {
75
// Header contains the request header fields either received by the server or to be sent by the client.
@@ -38,30 +36,3 @@ type CancelOperationOptions struct {
3836
// Header values set here will overwrite any SDK-provided values for the same key.
3937
Header Header
4038
}
41-
42-
// GetOperationResultOptions are options for the GetOperationResult client and server APIs.
43-
//
44-
// Deprecated: Getting a result from a handler is no longer supported.
45-
type GetOperationResultOptions struct {
46-
// Header contains the request header fields either received by the server or to be sent by the client.
47-
//
48-
// Header will always be non empty in server methods and can be optionally set in the client API.
49-
//
50-
// Header values set here will overwrite any SDK-provided values for the same key.
51-
Header Header
52-
// If non-zero, reflects the duration the caller has indicated that it wants to wait for operation completion,
53-
// turning the request into a long poll.
54-
Wait time.Duration
55-
}
56-
57-
// GetOperationInfoOptions are options for the GetOperationInfo client and server APIs.
58-
//
59-
// Deprecated: Getting info from a handler is no longer supported.
60-
type GetOperationInfoOptions struct {
61-
// Header contains the request header fields either received by the server or to be sent by the client.
62-
//
63-
// Header will always be non empty in server methods and can be optionally set in the client API.
64-
//
65-
// Header values set here will overwrite any SDK-provided values for the same key.
66-
Header Header
67-
}

nexus/unimplemented_handler.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,6 @@ func (h UnimplementedHandler) StartOperation(ctx context.Context, service, opera
1717
return nil, HandlerErrorf(HandlerErrorTypeNotImplemented, "not implemented")
1818
}
1919

20-
// GetOperationResult implements the Handler interface.
21-
func (h UnimplementedHandler) GetOperationResult(ctx context.Context, service, operation, token string, options GetOperationResultOptions) (any, error) {
22-
return nil, HandlerErrorf(HandlerErrorTypeNotImplemented, "not implemented")
23-
}
24-
25-
// GetOperationInfo implements the Handler interface.
26-
func (h UnimplementedHandler) GetOperationInfo(ctx context.Context, service, operation, token string, options GetOperationInfoOptions) (*OperationInfo, error) {
27-
return nil, HandlerErrorf(HandlerErrorTypeNotImplemented, "not implemented")
28-
}
29-
3020
// CancelOperation implements the Handler interface.
3121
func (h UnimplementedHandler) CancelOperation(ctx context.Context, service, operation, token string, options CancelOperationOptions) error {
3222
return HandlerErrorf(HandlerErrorTypeNotImplemented, "not implemented")

0 commit comments

Comments
 (0)