greetings

package
v0.0.0-...-c966403 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

README

Greetings

The greetings extension is a pointless extension that gives greetings to people.

The extension was developed to not speak with strangers and only recognises a few common Finnish names.

You can run an action (stateless, synchronous) or create an object (stateful, asynchronous) to get a greeting.

The example includes implementing:

  1. A controller (with a Reconciler and Validator)
  2. An actor
  3. A portal.

Running the example

  1. Run make dev to start the Horizon server in dev mode.
  2. Copy the credentials that are output and save it to a file nats.creds.
  3. Export the nats.creds for NATS to use it export NATS_CREDS=./nats.creds
  4. Run the greetings extention: go run ./examples/cmd/main.go

Once you start the server and create an account you should see the "Greetings" portal on the left:

greetings-screenshot

From there you can click around and greet some people.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Portal = hz.Portal{
	ObjectMeta: hz.ObjectMeta{
		Account: hz.RootAccount,
		Name:    extName,
	},
	Spec: &hz.PortalSpec{
		DisplayName: "Greetings",
		Icon:        gateway.IconCodeBracketSquare,
	},
}

Functions

This section is empty.

Types

type Greeting

type Greeting struct {
	hz.ObjectMeta `json:"metadata" cue:""`

	Spec   *GreetingSpec   `json:"spec,omitempty" cue:""`
	Status *GreetingStatus `json:"status,omitempty"`
}

func (Greeting) ObjectGroup

func (s Greeting) ObjectGroup() string

func (Greeting) ObjectKind

func (s Greeting) ObjectKind() string

func (Greeting) ObjectVersion

func (s Greeting) ObjectVersion() string

type GreetingReconciler

type GreetingReconciler struct {
	GreetingClient hz.ObjectClient[Greeting]
}

func (*GreetingReconciler) Reconcile

func (r *GreetingReconciler) Reconcile(
	ctx context.Context,
	req hz.Request,
) (hz.Result, error)

Reconcile implements hz.Reconciler.

type GreetingSpec

type GreetingSpec struct {
	// Name of the person to greet.
	Name string `json:"name,omitempty" cue:""`
}

GreetingSpec defines the desired state of Greeting.

type GreetingStatus

type GreetingStatus struct {
	// Ready indicates whether the greeting is ready.
	Ready bool `json:"ready"`
	// Error is the error message if the greeting failed.
	Error string `json:"error,omitempty" cue:",opt"`
	// Response is the response of the greeting.
	Response string `json:"response,omitempty" cue:",opt"`
}

GreetingStatus defines the observed state of Greeting.

type GreetingValidator

type GreetingValidator struct {
	hz.ZeroValidator
}

func (*GreetingValidator) ValidateCreate

func (*GreetingValidator) ValidateCreate(
	ctx context.Context,
	data []byte,
) error

type GreetingsHelloAction

type GreetingsHelloAction struct{}

func (GreetingsHelloAction) Action

func (GreetingsHelloAction) Action() string

Action implements hz.Action.

func (GreetingsHelloAction) Do

func (a GreetingsHelloAction) Do(
	ctx context.Context,
	greeting Greeting,
) (Greeting, error)

Do implements hz.Action.

type PortalHandler

type PortalHandler struct {
	Conn *nats.Conn
}

func (*PortalHandler) Router

func (h *PortalHandler) Router() *chi.Mux

type PortalRenderer

type PortalRenderer struct {
	Account string
	Portal  string
}

func (*PortalRenderer) URL

func (r *PortalRenderer) URL(steps ...string) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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