-
Notifications
You must be signed in to change notification settings - Fork 6
Add isWorker flag to actor startup #62
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
base: master
Are you sure you want to change the base?
Conversation
| return []byte(strconv.FormatBool(ta.shutdownWasCalled)), nil | ||
| case "getInstantiatePayload": | ||
| return ta.instantiatePayload, nil | ||
| return []byte(ta.instantiatePayload.Payload), nil |
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.
no byte cast here needed
|
|
||
| // InstantiatePayload provides the arguments for initialiazing actors on the STARTUP call. | ||
| type InstantiatePayload struct { | ||
| // IsWorker is a flag that is used to indicate whether the payload is intended for a worker or not |
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.
super nit: . at end
examples/file_cache/file_cache.go
Outdated
| return nil, fmt.Errorf("error unmarshaling InstantiatePayload: %w", err) | ||
| } | ||
| fcp := &FileCacheInstantiatePayload{} | ||
| if err := json.Unmarshal([]byte(p.Payload), fcp); err != nil { |
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.
dont need this cast
testdata/tinygo/util/main.go
Outdated
| // getInstantiatePayload returns the payload provided to the Startup invocation. | ||
| func getInstantiatePayload(payload []byte) ([]byte, error) { | ||
| return instantiatePayload, nil | ||
| return []byte(instantiatePayload.Payload), nil |
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.
dont need this cast
|
|
||
| return r.activations.invoke(ctx, reference, operation, create.InstantiatePayload, payload, false) | ||
| // Wrap instantiation payload into a struct that provides metadata to the actor | ||
| b, err := json.Marshal(types.InstantiatePayload{Payload: create.InstantiatePayload, IsWorker: false}) |
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.
I think we should push these down into activations.go that way we can avoid the allocations/marshalling work except for the case where a new actor is actually being created which will make it ~free
This PR adds a flag to actor instantiations on the startup call so that apart from the payload user specifies, also an
IsWorkerflag is passed. This allows actors to know if they are being run as workers or not and consequently decide if they can use the transaction or not.