messaging

package
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bridges

func Bridges(mqtt bool, websocket bool) basic.Op

func Channel

func Channel(regex bool, match string) basic.Op

func Description

func Description(value string) basic.Op

func Id

func Id(value string) basic.Op

func Local

func Local(value bool) basic.Op

func SmartOps

func SmartOps(value []string) basic.Op

func Tags

func Tags(value []string) basic.Op

Types

type Getter

type Getter interface {
	basic.ResourceGetter[*structureSpec.Messaging]
	Local() bool
	Regex() bool
	ChannelMatch() string
	MQTT() bool
	WebSocket() bool
}

func Yaml

func Yaml(name, application string, yamlData []byte) (Getter, error)

type Messaging

type Messaging interface {
	Get() Getter
	common.Resource[*structureSpec.Messaging]
}
Example
package main

import (
	"fmt"

	"github.com/spf13/afero"
	"github.com/taubyte/tau/pkg/schema/messaging"
	"github.com/taubyte/tau/pkg/schema/project"
)

func main() {
	// Create a new file system in memory
	fs := afero.NewMemMapFs()

	// Open a new project with a virtual file system
	project, err := project.Open(project.VirtualFS(fs, "/"))
	if err != nil {
		return
	}

	// Create or open an messaging
	msg, err := project.Messaging("test_msg", "")
	if err != nil {
		return
	}

	// Set and write messaging fields
	err = msg.Set(true,
		messaging.Id("QmaEBKzOyrYL1D6gtqD86Nyr2hvXAxWHcMCu9ffxLaByMc"),
		messaging.Description("a basic messaging"),
		messaging.Tags([]string{"tag1", "tag2"}),
		messaging.Local(false),
		messaging.Channel(false, "simpleChannel"),
		messaging.Bridges(false, true),
	)
	if err != nil {
		return
	}

	// Display the Description
	fmt.Println(msg.Get().Description())

	// Open the config.yaml of the messaging
	config, err := afero.ReadFile(fs, "/messaging/test_msg.yaml")
	if err != nil {
		return
	}

	// Print config.yaml
	fmt.Println(string(config))

}
Output:

a basic messaging
id: QmaEBKzOyrYL1D6gtqD86Nyr2hvXAxWHcMCu9ffxLaByMc
description: a basic messaging
tags:
    - tag1
    - tag2
local: false
channel:
    regex: false
    match: simpleChannel
bridges:
    mqtt:
        enable: false
    websocket:
        enable: true

func Open

func Open(seer *seer.Seer, name string, application string) (Messaging, error)

Jump to

Keyboard shortcuts

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