Skip to content

Java demo project using Spawn to find postal codes at ViaCEP.

Notifications You must be signed in to change notification settings

h3nrique/postalcode-spawn-demo

Repository files navigation

Postalcode Spawn Demo

Java demo project using Spawn to find postal codes at ViaCEP.

Test

Before running the Maven command, ensure that a container environment (Docker/Podman) is running.

mvn test

Start local environment

docker compose up

Test local environment

# Request PostalCode
curl -v -H 'Content-Type: application/json' -d '{ "postalCode": "03568000" }' 'http://localhost:8080/postalcode'

# Get PostalCode info
curl -v 'http://localhost:8080/postalcode/03568000'

To deploy on Openshift with Openshift Pipeline (Tekton)

oc create ns spawn
oc process openshift//mysql-persistent -p MYSQL_USER=admin -p MYSQL_PASSWORD=admin -p MYSQL_ROOT_PASSWORD=mypassword -p MYSQL_DATABASE=eigr | oc create -n spawn -f -
oc create secret generic mysql-connection-secret -n eigr-functions --from-literal=database=eigr --from-literal=host='mysql.spawn.svc.cluster.local' --from-literal=port='3306' --from-literal=username='admin' --from-literal=password='admin' --from-literal=encryptionKey=$(openssl rand -base64 32)
tee actorsystem.yaml << END
apiVersion: spawn-eigr.io/v1
kind: ActorSystem
metadata:
  name: spawn-demo
  labels:
    app: spawn-demo
spec:
#  selector:
#    app: spawn-demo
  statestore:
    type: MySql
    credentialsSecretRef: mysql-connection-secret
    pool:
      size: "10"
END
oc create -f actorsystem.yaml -n spawn
oc create -f openshift-pipeline.yaml -n spawn
oc create role actorhost-pipeline --verb='*' --resource='actorhosts,actorsystems' -n spawn
oc create rolebinding actorhost-pipeline --role=actorhost-pipeline --serviceaccount=spawn:pipeline -n spawn
# If you want to expose actor service with route command
oc create route edge postalcode --service=postalcode-spawn-demo --port=8080

About

Java demo project using Spawn to find postal codes at ViaCEP.

Topics

Resources

Stars

Watchers

Forks