MCPcopy
hub / github.com/kopia/kopia / GetSender

Function GetSender

notification/sender/sender.go:53–65  ·  view source on GitHub ↗

GetSender returns a new instance of a sender with a given name and options.

(ctx context.Context, profile string, method Method, jsonOptions any)

Source from the content-addressed store, hash-verified

51
52// GetSender returns a new instance of a sender with a given name and options.
53func 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.
68func Register[T any](method Method, p Factory[*T]) {

Callers 15

TestEmailProviderFunction · 0.92
TestEmailProvider_TextFunction · 0.92
TestEmailProvider_AUTHFunction · 0.92
TestPushoverFunction · 0.92
TestPushover_InvalidFunction · 0.92
TestProviderFunction · 0.92
TestWebhookFunction · 0.92
TestWebhook_FailureFunction · 0.92
TestWebhook_InvalidURLFunction · 0.92

Calls 1

ErrorfMethod · 0.80

Tested by 13

TestEmailProviderFunction · 0.74
TestEmailProvider_TextFunction · 0.74
TestEmailProvider_AUTHFunction · 0.74
TestPushoverFunction · 0.74
TestPushover_InvalidFunction · 0.74
TestProviderFunction · 0.74
TestWebhookFunction · 0.74
TestWebhook_FailureFunction · 0.74
TestWebhook_InvalidURLFunction · 0.74