jsonobj

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: 3 Imported by: 0

README

JSON Object Example

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

What's Going On

The file workflow.go has two functions defined:

  • GetInfo, which is a Task Function (task accepts a struct as an input variable; only pointers to struct are supported).
  • MyWorkflowGet, 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 ./jsonobj/worker

Leave that process running.

Register the WfSpec

Next, in another terminal, run:

go run ./jsonobj/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"}}'

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 GetInfo

func GetInfo(input *InputData) string

func MyWorkflowGet

func MyWorkflowGet(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