Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DRAFT FOR FEEDBACK - Main b 21669 doc viewer file upload status per s3 events #14347

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
25624b9
B-21669 - add UPLOAD_DOC_STATUS constant w/ setTimeout UI.
ryan-mchugh Nov 20, 2024
8db737d
B-21669 - transitory steps. using broken status based on aws tags
ryan-mchugh Nov 21, 2024
f4c1b2b
B-21669 - add first api endpoint for getUploadStatus
ryan-mchugh Nov 22, 2024
3201e23
B-21669 - mock with custom endpoint using eventsource and text/event-…
ryan-mchugh Nov 29, 2024
ebdbb93
B-21669 - fix race on useEffect.
ryan-mchugh Dec 3, 2024
07e55eb
B-21669 - fix uploading status.
ryan-mchugh Dec 3, 2024
64c6f5a
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-21669-d…
ryan-mchugh Dec 6, 2024
2956915
B-21669 - minimal test for draft.
ryan-mchugh Dec 9, 2024
110fd12
B-21669 - switch to reading av_status value from db - intial work.
ryan-mchugh Dec 16, 2024
048fd76
B-21669 - continuously reading from the db.
ryan-mchugh Dec 17, 2024
de88145
B-21669 - sqs initial setup.
ryan-mchugh Dec 24, 2024
b273296
B-21669 - sqs working
ryan-mchugh Dec 27, 2024
c945413
B-21669 - sqs working w/ frontend.
ryan-mchugh Dec 27, 2024
b692a90
B-21669 - arn constructed from env vars.
ryan-mchugh Dec 27, 2024
9597f08
Merge branch 'main' of github.com:transcom/mymove into MAIN-B-21669-d…
ryan-mchugh Dec 30, 2024
60237c2
B-21669 - remove unused avstatus on db; add cancel context for reques…
ryan-mchugh Dec 31, 2024
dbc9a18
B-21669 - unique queues, working on destuction of queue and subscript…
ryan-mchugh Jan 2, 2025
762ff6f
B-21669 - environment vars and receiver cleanup.
ryan-mchugh Jan 3, 2025
08087ce
B-21669 - stub notification receiver.
ryan-mchugh Jan 3, 2025
65b0b3a
B-21669 - faked notification receiver working for local.
ryan-mchugh Jan 6, 2025
74545d0
B-21669 - working on unit tests.
ryan-mchugh Jan 6, 2025
c4355c5
B-21669 - working test under routing with stub.
ryan-mchugh Jan 7, 2025
f825bef
B-21669 - trying to mock dependencies.
ryan-mchugh Jan 7, 2025
bd2254b
B-21669 - working test with mock sns & sqs services.
ryan-mchugh Jan 7, 2025
6e122f4
B-21669 - working close call on server; cleanup for handler.
ryan-mchugh Jan 7, 2025
2fa55a1
B-21669 - fix tests and error handling on endpoint.
ryan-mchugh Jan 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .envrc
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,17 @@ export TZ="UTC"
#
# export STORAGE_BACKEND=s3
# export EMAIL_BACKEND=ses
# export RECEIVER_BACKEND="sns&sqs"
#
# Instructions for using S3 storage backend here: https://dp3.atlassian.net/wiki/spaces/MT/pages/1470955567/How+to+test+storing+data+in+S3+locally
# Instructions for using SES email backend here: https://dp3.atlassian.net/wiki/spaces/MT/pages/1467973894/How+to+test+sending+email+locally
# Instructions for using SNS&SQS backend here: ...
#
# The default and equivalent to not being set is:
#
# export STORAGE_BACKEND=local
# export EMAIL_BACKEND=local
# export RECEIVER_BACKEND=local
#
# Setting region and profile conditionally while we migrate from com to govcloud.
if [ "$STORAGE_BACKEND" == "s3" ]; then
Expand All @@ -255,6 +258,11 @@ export AWS_S3_KEY_NAMESPACE=$USER
export AWS_SES_DOMAIN="devlocal.dp3.us"
export AWS_SES_REGION="us-gov-west-1"

if [ "$RECEIVER_BACKEND" == "sns&sqs" ]; then
export AWS_SNS_OBJECT_TAGS_ADDED_TOPIC="app_s3_tag_events"
export AWS_SNS_REGION="us-gov-west-1"
fi

# To use s3 links aws-bucketname/xx/user/ for local builds,
# you'll need to add the following to your .envrc.local:
#
Expand Down Expand Up @@ -441,4 +449,4 @@ then
fi

# Check that all required environment variables are set
check_required_variables
check_required_variables
4 changes: 4 additions & 0 deletions cmd/milmove/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -478,6 +478,9 @@ func buildRoutingConfig(appCtx appcontext.AppContext, v *viper.Viper, redisPool
appCtx.Logger().Fatal("notification sender sending not enabled", zap.Error(err))
}

// Email
notificationReceiver, _ := notifications.InitReceiver(v, appCtx.Logger())

routingConfig.BuildRoot = v.GetString(cli.BuildRootFlag)
sendProductionInvoice := v.GetBool(cli.GEXSendProdInvoiceFlag)

Expand Down Expand Up @@ -567,6 +570,7 @@ func buildRoutingConfig(appCtx appcontext.AppContext, v *viper.Viper, redisPool
dtodRoutePlanner,
fileStorer,
notificationSender,
notificationReceiver,
iwsPersonLookup,
sendProductionInvoice,
gexSender,
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ require (
github.com/aws/aws-sdk-go-v2/service/rds v1.78.2
github.com/aws/aws-sdk-go-v2/service/s3 v1.59.0
github.com/aws/aws-sdk-go-v2/service/ses v1.25.3
github.com/aws/aws-sdk-go-v2/service/sns v1.31.8
github.com/aws/aws-sdk-go-v2/service/sqs v1.34.6
github.com/aws/aws-sdk-go-v2/service/ssm v1.52.8
github.com/aws/aws-sdk-go-v2/service/sts v1.30.7
github.com/aws/smithy-go v1.20.4
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ github.com/aws/aws-sdk-go-v2/service/s3 v1.59.0 h1:Cso4Ev/XauMVsbwdhYEoxg8rxZWw4
github.com/aws/aws-sdk-go-v2/service/s3 v1.59.0/go.mod h1:BSPI0EfnYUuNHPS0uqIo5VrRwzie+Fp+YhQOUs16sKI=
github.com/aws/aws-sdk-go-v2/service/ses v1.25.3 h1:wcfUsE2nqsXhEj68gxr7MnGXNPcBPKx0RW2DzBVgVlM=
github.com/aws/aws-sdk-go-v2/service/ses v1.25.3/go.mod h1:6Ul/Ir8oOCsI3dFN0prULK9fvpxP+WTYmlHDkFzaAVA=
github.com/aws/aws-sdk-go-v2/service/sns v1.31.8 h1:vRSk062d1SmaEVbiqFePkvYuhCTnW2JnPkUdt19nqeY=
github.com/aws/aws-sdk-go-v2/service/sns v1.31.8/go.mod h1:wjhxA9hlVu75dCL/5Wcx8Cwmszvu6t0i8WEDypcB4+s=
github.com/aws/aws-sdk-go-v2/service/sqs v1.34.6 h1:DbjODDHumQBdJ3T+EO7AXVoFUeUhAsJYOdjStH5Ws4A=
github.com/aws/aws-sdk-go-v2/service/sqs v1.34.6/go.mod h1:7idt3XszF6sE9WPS1GqZRiDJOxw4oPtlRBXodWnCGjU=
github.com/aws/aws-sdk-go-v2/service/ssm v1.52.8 h1:7cjN4Wp3U3cud17TsnUxSomTwKzKQGUWdq/N1aWqgMk=
github.com/aws/aws-sdk-go-v2/service/ssm v1.52.8/go.mod h1:nUSNPaG8mv5rIu7EclHnFqZOjhreEUwRKENtKTtJ9aw=
github.com/aws/aws-sdk-go-v2/service/sso v1.22.7 h1:pIaGg+08llrP7Q5aiz9ICWbY8cqhTkyy+0SHvfzQpTc=
Expand Down
53 changes: 53 additions & 0 deletions pkg/cli/receiver.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package cli

import (
"fmt"

"github.com/spf13/pflag"
"github.com/spf13/viper"
)

const (
// ReceiverBackend is the Receiver Backend Flag
ReceiverBackendFlag string = "receiver-backend"
// AWSSNSObjectTagsAddedTopic is the AWS SNS Object Tags Added Topic Flag
AWSSNSObjectTagsAddedTopicFlag string = "aws-sns-object-tags-added-topic"
// AWSS3RegionFlag is the AWS SNS Region Flag
AWSSNSRegionFlag string = "aws-sns-region"
// AWSSNSAccountId is the application's AWS account id
AWSSNSAccountId string = "aws-account-id"
)

// InitReceiverFlags initializes Storage command line flags
func InitReceiverFlags(flag *pflag.FlagSet) {
flag.String(ReceiverBackendFlag, "local", "Receiver backend to use, either local or sns&sqs.")
flag.String(AWSSNSObjectTagsAddedTopicFlag, "", "SNS Topic for receiving event messages")
flag.String(AWSSNSRegionFlag, "", "AWS region used for SNS and SQS")
flag.String(AWSSNSAccountId, "", "AWS account Id")
}

// CheckReceiver validates Storage command line flags
func CheckReceiver(v *viper.Viper) error {

receiverBackend := v.GetString(ReceiverBackendFlag)
if !stringSliceContains([]string{"local", "sns&sqs"}, receiverBackend) {
return fmt.Errorf("invalid receiver-backend %s, expecting local or sns&sqs", receiverBackend)
}

if receiverBackend == "sns&sqs" {
r := v.GetString(AWSSNSRegionFlag)
if r == "" {
return fmt.Errorf("invalid value for %s: %s", AWSSNSRegionFlag, r)
}
topic := v.GetString(AWSSNSObjectTagsAddedTopicFlag)
if topic == "" {
return fmt.Errorf("invalid value for %s: %s", AWSSNSObjectTagsAddedTopicFlag, topic)
}
accountId := v.GetString(AWSSNSAccountId)
if topic == "" {
return fmt.Errorf("invalid value for %s: %s", AWSSNSAccountId, accountId)
}
}

return nil
}
6 changes: 6 additions & 0 deletions pkg/cli/receiver_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package cli

func (suite *cliTestSuite) TestConfigReceiver() {
suite.Setup(InitReceiverFlags, []string{})
suite.NoError(CheckReceiver(suite.viper))
}
9 changes: 9 additions & 0 deletions pkg/gen/internalapi/configure_mymove.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package internalapi

import (
"crypto/tls"
"io"
"net/http"

"github.com/go-openapi/errors"
Expand Down Expand Up @@ -60,6 +61,9 @@ func configureAPI(api *internaloperations.MymoveAPI) http.Handler {

api.BinProducer = runtime.ByteStreamProducer()
api.JSONProducer = runtime.JSONProducer()
api.TextEventStreamProducer = runtime.ProducerFunc(func(w io.Writer, data interface{}) error {
return errors.NotImplemented("textEventStream producer has not yet been implemented")
})

// You may change here the memory limit for this multipart form parser. Below is the default (32 MB).
// ppm.CreatePPMUploadMaxParseMemory = 32 << 20
Expand Down Expand Up @@ -205,6 +209,11 @@ func configureAPI(api *internaloperations.MymoveAPI) http.Handler {
return middleware.NotImplemented("operation transportation_offices.GetTransportationOffices has not yet been implemented")
})
}
if api.UploadsGetUploadStatusHandler == nil {
api.UploadsGetUploadStatusHandler = uploads.GetUploadStatusHandlerFunc(func(params uploads.GetUploadStatusParams) middleware.Responder {
return middleware.NotImplemented("operation uploads.GetUploadStatus has not yet been implemented")
})
}
if api.EntitlementsIndexEntitlementsHandler == nil {
api.EntitlementsIndexEntitlementsHandler = entitlements.IndexEntitlementsHandlerFunc(func(params entitlements.IndexEntitlementsParams) middleware.Responder {
return middleware.NotImplemented("operation entitlements.IndexEntitlements has not yet been implemented")
Expand Down
1 change: 1 addition & 0 deletions pkg/gen/internalapi/doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

104 changes: 104 additions & 0 deletions pkg/gen/internalapi/embedded_spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions pkg/gen/internalapi/internaloperations/mymove_api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading