GetSender returns a new instance of a sender with a given name and options.
(ctx context.Context, profile string, method Method, jsonOptions any)
| 51 | |
| 52 | // GetSender returns a new instance of a sender with a given name and options. |
| 53 | func GetSender(ctx context.Context, profile string, method Method, jsonOptions any) (Sender, error) { |
| 54 | factory := allSenders[method] |
| 55 | if factory == nil { |
| 56 | return nil, errors.Errorf("unknown sender: %v", method) |
| 57 | } |
| 58 | |
| 59 | sp, err := factory(ctx, jsonOptions) |
| 60 | if err != nil { |
| 61 | return nil, errors.Wrap(err, "unable to create sender") |
| 62 | } |
| 63 | |
| 64 | return senderWrapper{sp, profile}, nil |
| 65 | } |
| 66 | |
| 67 | // Register registers a new provider with a given name and factory function. |
| 68 | func Register[T any](method Method, p Factory[*T]) { |