func (w *workerImpl) SeqID() uint64 {
	return atomic.AddUint64(&w.seqID, 1)
}
SeqID - sequence id
package workflow
import (
	"context"
	"sync"
	"sync/atomic"
	"time"
	"github.com/spiral/errors"
	"github.com/spiral/roadrunner-plugins/v2/logger"
	"github.com/spiral/roadrunner-plugins/v2/server"
	"github.com/spiral/roadrunner/v2/events"
	"github.com/spiral/roadrunner/v2/payload"
	rrPool "github.com/spiral/roadrunner/v2/pool"
	rrWorker "github.com/spiral/roadrunner/v2/worker"
	roadrunner_temporal "github.com/temporalio/roadrunner-temporal"
	"github.com/temporalio/roadrunner-temporal/client"
	rrt "github.com/temporalio/roadrunner-temporal/protocol"
	bindings "go.temporal.io/sdk/internalbindings"
	tWorker "go.temporal.io/sdk/worker"
	"go.temporal.io/sdk/workflow"
)
const RR_MODE = "RR_MODE"  
const RR_CODEC = "RR_CODEC"  
type pool interface {
	SeqID() uint64
	Exec(p *payload.Payload) (*payload.Payload, error)
	Start(ctx context.Context, temporal client.Temporal) error
	Destroy(ctx context.Context) error
	Workers() []rrWorker.BaseProcess
	Pool() rrPool.Pool
	WorkflowNames() []string
}
type workerImpl struct {
	sync.Mutex
	codec     rrt.Codec
	seqID     uint64
	workflows map[string]rrt.WorkflowInfo
	tWorkers  []tWorker.Worker
	pool      rrPool.Pool
	log logger.Logger
	graceTimeout time.Duration
}
func newPool(codec rrt.Codec, factory server.Server, graceTimeout time.Duration, log logger.Logger, listener ...events.Listener) (pool, error) {
	const op = errors.Op("new_workflow_pool")
	env := map[string]string{RR_MODE: roadrunner_temporal.RRMode, RR_CODEC: codec.GetName()}
	cfg := &rrPool.Config{
		Debug:           false,
		NumWorkers:      1,
		MaxJobs:         0,
		AllocateTimeout: time.Hour * 240,
		DestroyTimeout:  time.Second * 30,
		Supervisor: nil,
	}
	p, err := factory.NewWorkerPool(
		context.Background(),
		cfg,
		env,
		listener...,
	)
	if err != nil {
		return nil, errors.E(op, err)
	}
	wrk := &workerImpl{
		codec:        codec,
		pool:         p,
		log:          log,
		graceTimeout: graceTimeout,
	}
	return wrk, nil
}
func (w *workerImpl) Start(ctx context.Context, temporal client.Temporal) error {
	const op = errors.Op("workflow_pool_start")
	err := w.initPool(ctx, temporal)
	if err != nil {
		return errors.E(op, err)
	}
	for i := 0; i < len(w.tWorkers); i++ {
		err = w.tWorkers[i].Start()
		if err != nil {
			return errors.E(op, err)
		}
	}
	return nil
}
func (w *workerImpl) Destroy(ctx context.Context) error {
	w.Lock()
	defer w.Unlock()
	for i := 0; i < len(w.tWorkers); i++ {
		w.tWorkers[i].Stop()
	}
	w.log.Debug("workerImpl destroy")
	tWorker.PurgeStickyWorkflowCache()
	w.pool.Destroy(ctx)
	return nil
}
func (w *workerImpl) Pool() rrPool.Pool {
	w.Lock()
	defer w.Unlock()
	return w.pool
}
func (w *workerImpl) NewWorkflowDefinition() bindings.WorkflowDefinition {
	return &workflowProcess{
		codec: w.codec,
		pool:  w,
	}
}