-
Notifications
You must be signed in to change notification settings - Fork 12
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
feat: new Mapper example which serves as a slow container for testing purposes #172
Conversation
Signed-off-by: Julie Vogelman <[email protected]>
… for the purpose of serving as a slow container for testing Signed-off-by: Julie Vogelman <[email protected]>
Signed-off-by: Julie Vogelman <[email protected]>
} | ||
|
||
func (e *CatSleep) Map(ctx context.Context, keys []string, d mapper.Datum) mapper.Messages { | ||
time.Sleep(10 * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make the duration configurable? thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@juliev0 do you plan to constantly use this image to run e2e tests? If so, numaflow-go
supports auto-updating the image such that the quay.io/numaio/numaflow-go/map-cat-sleep:stable
image is always up-to-date(using the numaflow-go main). If you want this image to be auto-updated every time we change numaflow-go SDK, please add it in the auto-build list.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks! I will do that. I was actually wondering if I'd need to go in here all the time and update that.
Signed-off-by: Julie Vogelman <[email protected]>
Signed-off-by: Julie Vogelman <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT
func (e *CatSleep) Map(ctx context.Context, keys []string, d mapper.Datum) mapper.Messages { | ||
|
||
// sleep for as long as the environment variable indicates (or default if not configured) | ||
sleepSeconds := DEFAULT_SLEEP_SECONDS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you could move this inside CatSleep
?
secondsString := os.Getenv("SLEEP_SECONDS") | ||
if secondsString == "" { | ||
log.Printf("SLEEP_SECONDS environment variable not set, using default %d seconds\n", DEFAULT_SLEEP_SECONDS) | ||
} else { | ||
val, err := strconv.Atoi(secondsString) | ||
if err != nil { | ||
log.Printf("SLEEP_SECONDS environment variable %q not an int, using default %d seconds\n", secondsString, DEFAULT_SLEEP_SECONDS) | ||
} else { | ||
sleepSeconds = val | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be done in main?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True. I suppose I can make this purposely slow container more efficient. :D
but it would still be neater though, I agree
sleepSeconds = val | ||
} | ||
} | ||
time.Sleep(time.Duration(sleepSeconds) * time.Second) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time.Sleep(time.Duration(sleepSeconds) * time.Second) | |
time.Sleep(time.Duration(e.sleepSeconds) * time.Second) |
…fewer redundant calls Signed-off-by: Julie Vogelman <[email protected]>
Decided to rename to 'slow cat' and also relocated the logic to reduce code redundancy (and reduce log spew, which would've been pretty ugly too) (thanks for the suggestion @vigith) |
By the way, I've tested the image out in my pipeline, both with and without environment variable specified. |
For Numaplane, it's useful to be able to simulate a slow Vertex. This does a single "cat" but does a sleep first.
Sleep time is configurable by environment variable.