https://github.com/mjs/aw-golang_sample_agent
A minimal remote agent example for ActiveWorkflow in Go
https://github.com/mjs/aw-golang_sample_agent
activeworkflow golang golang-examples
Last synced: 2 months ago
JSON representation
A minimal remote agent example for ActiveWorkflow in Go
- Host: GitHub
- URL: https://github.com/mjs/aw-golang_sample_agent
- Owner: mjs
- License: mit
- Created: 2021-01-31T10:49:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-03-11T10:51:34.000Z (over 4 years ago)
- Last Synced: 2025-01-18T14:33:38.751Z (5 months ago)
- Topics: activeworkflow, golang, golang-examples
- Language: Go
- Homepage: https://www.activeworkflow.org/
- Size: 4.88 KB
- Stars: 5
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ActiveWorkflow Agent Example in Go
This project implements a simple example agent for [ActiveWorkflow](https://github.com/automaticmode/active_workflow).
The agent is implemented in Go and uses the [remote agent API](https://docs.activeworkflow.org/remote-agent-api).This agent doesn't do anything particularly useful but demonstrates some of the
features of ActiveWorkflow's Remote Agent API. The agent simply records the the
number of `check` and `receive` calls it sees in memory and returns messages
with the current count.## Quick Start
This agent is intended to be used as part of [ActiveWorkflow](https://github.com/automaticmode/active_workflow).
To get started with ActiveWorkflow please see the [ActiveWorkflow documentation](https://docs.activeworkflow.org/).You will need a working Go toolchain installed. There are no external
dependencies. The agent is built with just the Go standard library.Please make sure you run this agent *before* starting ActiveWorkflow. The
agent can be started without a compile step, like this:```sh
go run agent.go
```Alternatively, you can compile it first and then run it:
```sh
go build -o agent .
./agent
```Note the URL of the agent's server (usually `http://127.0.0.1:5000/`), and set
it as an environment variable for ActiveWorkflow:```sh
export REMOTE_AGENT_URL="http://127.0.0.1:5000/"
```
Now you can start ActiveWorkflow. You should be able to create instances of
this agent (named "Go Test Counter Agent"). Run it and send messages to it.If using [Docker to run ActiveWorkflow](https://docs.activeworkflow.org/#running-locally-with-docker),
you'll need to use the `-e` parameter to `docker run` to pass `REMOTE_AGENT_URL` through
to ActiveWorkflow. The address in the URL will also have to be updated to match where the agent
is running (`127.0.0.1` is unlikely to be correct). Docker provides `host.docker.internal` for the host IP.
Thus, you could run:
```sh
docker run -e REMOTE_AGENT_URL="http://host.docker.internal:5000/" -p 3000:3000 --rm automaticmode/active_workflow
```Please note that this project is just a minimal example. Consider using a
proper project structure when developing your own ActiveWorkflow agents.