jsonarray

package
v0.0.0-...-0f879ca Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 10, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

README

JSON Array Example

This is a "hello-world" with a JSON Array example of LittleHorse using GoLang.

What's Going On

The file workflow.go has two functions defined:

  • AddUpList, which is a Task Function (task accepts a slice as an input variable; only pointers to slice are supported).
  • MyWorkflowAdd, which is the Workflow Function.

Deploy the Task Worker

Before we can create the WfSpec, we need to register the TaskDef. The easiest way to do that is to run the task worker:

go run ./jsonarray/worker

Leave that process running.

Register the WfSpec

Next, in another terminal, run:

go run ./jsonarray/deploy

That will create the WfSpec. You can verify that via:

lhctl get wfSpec my-workflow

Run a WfRun

To run a WfRun, you can use lhctl.

lhctl run my-workflow input '[{"foo": 1, "art":{"id":1,"title": "bugia", "content": "lol"}},{"foo":103, "art":{"id":1,"title": null}}]'

It will print out an ID. You can view the status of that WfRun via:

lhctl get wfRun <the id from the previous step>

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUpList

func AddUpList(inputs *[]InputData) int

func MyWorkflowAdd

func MyWorkflowAdd(thread *wflib.ThreadBuilder)

Types

type Article

type Article struct {
	Id      int    `json:"id"`
	Title   string `json:"title,omitempty"`
	Content string `json:"content,omitempty"`
}

type InputData

type InputData struct {
	Foo int     `json:"foo"`
	Art Article `json:"art"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL