Skip to content

Conversation

@aratz-lasa
Copy link
Collaborator

This PR adds a flag to actor instantiations on the startup call so that apart from the payload user specifies, also an IsWorker flag 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.

return []byte(strconv.FormatBool(ta.shutdownWasCalled)), nil
case "getInstantiatePayload":
return ta.instantiatePayload, nil
return []byte(ta.instantiatePayload.Payload), nil
Copy link
Owner

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nit: . at end

return nil, fmt.Errorf("error unmarshaling InstantiatePayload: %w", err)
}
fcp := &FileCacheInstantiatePayload{}
if err := json.Unmarshal([]byte(p.Payload), fcp); err != nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont need this cast

// getInstantiatePayload returns the payload provided to the Startup invocation.
func getInstantiatePayload(payload []byte) ([]byte, error) {
return instantiatePayload, nil
return []byte(instantiatePayload.Payload), nil
Copy link
Owner

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})
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants