-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package snssqs | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
|
||
"github.com/aws/aws-sdk-go-v2/service/sns" | ||
"github.com/aws/aws-sdk-go-v2/service/sqs" | ||
transport "github.com/aws/smithy-go/endpoints" | ||
"github.com/w-h-a/pkg/broker" | ||
) | ||
|
||
type snsResolver struct { | ||
options broker.PublishOptions | ||
} | ||
|
||
func (r *snsResolver) ResolveEndpoint(ctx context.Context, params sns.EndpointParameters) (transport.Endpoint, error) { | ||
if len(r.options.Endpoint) == 0 { | ||
return sns.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params) | ||
} | ||
|
||
u, err := url.Parse(r.options.Endpoint) | ||
if err != nil { | ||
return transport.Endpoint{}, err | ||
} | ||
|
||
return transport.Endpoint{ | ||
URI: *u, | ||
}, nil | ||
} | ||
|
||
type sqsResolver struct { | ||
options broker.SubscribeOptions | ||
} | ||
|
||
func (r *sqsResolver) ResolveEndpoint(ctx context.Context, params sqs.EndpointParameters) (transport.Endpoint, error) { | ||
if len(r.options.Endpoint) == 0 { | ||
return sqs.NewDefaultEndpointResolverV2().ResolveEndpoint(ctx, params) | ||
} | ||
|
||
u, err := url.Parse(r.options.Endpoint) | ||
if err != nil { | ||
return transport.Endpoint{}, err | ||
} | ||
|
||
return transport.Endpoint{ | ||
URI: *u, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters