roadrunner-server / roadrunner-plugins

📦 Home for the roadrunner plugins
MIT License
25 stars 9 forks source link

[💡 FEATURE REQUEST]: Custom worker #194

Closed Yurunsoft closed 2 years ago

Yurunsoft commented 2 years ago

Plugin

No response

I have an idea!

I have an idea, listen to me!!

Can I customize the worker? Like HTTP, I can define commands, pools, etc

rpc:
  listen: tcp://127.0.0.1:6001

server:
  command: "php worker.php"

http:
  address: "0.0.0.0:8080"

worker:
  - name: myWorker
    command: "php my-worker.php"
    pool:
      num_workers: 4

logs:
  level: error

I hope to rely on the resident memory feature of roadrunner to implement my own worker.

rustatian commented 2 years ago

Hey @Yurunsoft, this is a good idea. But, from the RR2 POV, this is not a worker (like in the RR1), it's the pool. We already have similar a proposal: https://github.com/spiral/roadrunner-plugins/issues/36

rustatian commented 2 years ago

@Yurunsoft You are saying about worker customization, what do you mean here?

Yurunsoft commented 2 years ago

I hope to write an endless loop in the custom worker process to achieve some functions, such as cron. Temporal is too bloated.

rustatian commented 2 years ago

I hope to write an endless loop in the custom worker process to achieve some functions, such as cron. Temporal is too bloated.

To create your own worker you only need to implement the goridge protocol to communicate with the RR: https://github.com/spiral/goridge/blob/master/pkg/frame/frame.md

It's already implemented in the https://github.com/spiral/goridge-php library. You may have a look at the https://github.com/spiral/roadrunner-worker

Yurunsoft commented 2 years ago

Thanks, this has solved my problem https://roadrunner.dev/docs/beep-beep-service