import "github.com/blueprint-uservices/blueprint/plugins/workflow"
Package workflow instantiates services defined in the application's workflow spec.
A "Workflow Spec" or just "Workflow" defines the core business logic of an application. For example, in a social network application, the workflow defines how users can upload posts, view their timeline feed, follow other users, etc.
Users of Blueprint are responsible for writing their application's workflow spec. They then make use of Blueprint's compiler, and this workflow plugin, to compile the workflow spec into an application.
See the Workflow User Manual Page for more details on writing workflows.
You can instantiate a service and give it a name, providing the service's interface or implementation type as the type parameter:
payment_service := workflow.Service[payment.PaymentService](spec, "payment_service")
If a service has arguments (e.g. another service, a backend), then those arguments can be added to the call:
user_db := simple.NoSQLDB(spec, "user_db")
user_service := workflow.Service[user.UserService](spec, "user_service", user_db)
If a service has configuration value arguments (e.g. a timeout) then string values can be provided for those arguments:
payment_service := workflow.Service[payment.PaymentService](spec, "payment_service", "500")
The arguments provided to a service must match the arguments needed by the service's constructor in the workflow spec. If they do not match, you will see a compilation error.
The workflow spec service implementation will be copied into the output directory. Where appropriate, the plugin generates constructor invocations, passing clients of other services/backends as constructor arguments.
func Service
func Service[ServiceType any](spec wiring.WiringSpec, serviceName string, serviceArgs ...string) string
Service is used by wiring specs to instantiate services from the workflow spec.
Type parameter [ServiceType] is used to specify the type of the service. It can be the name of an interface or an implementing struct. [ServiceType] must be a valid workflow service: all interface methods must have context.Context arguments and [error] return values, and a constructor must be defined.
`serviceName` is a unique name for the service instance.
`serviceArgs` must correspond to the arguments of the service's constructor within the workflow spec. They can either be the names of other nodes that exist within this wiring spec, or string values for configuration arguments. This determination is made by looking at the argument types of the constructor within the workflow spec (string arguments are treated as configuration; everything else is treated as a service instance).
After calling Service, serviceName is an application-level golang service. Application-level modifiers can be applied to it, or it can be further deployed into e.g. a goproc, a linuxcontainer, etc.
Generated by gomarkdoc