event

package
v0.3.9 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event uint32

func (Event) Channel

func (e Event) Channel() (*pubsubNode.ChannelObject, error)

Channel will get the name of the event's channel returns a ChannelObject and an error

Example
package main

import (
	"fmt"

	symbols "github.com/taubyte/go-sdk-symbols/pubsub/event"
	"github.com/taubyte/go-sdk/event"

	_ "github.com/taubyte/go-sdk/pubsub/event"
)

func main() {
	// Mocking the calls to the vm for usage in tests and playground
	symbols.MockData{
		Channel: "someChannel",
	}.Mock()

	// An event that would be received by a taubyte function
	var e event.Event

	pubSubEvent, err := e.PubSub()
	if err != nil {
		return
	}

	channel, err := pubSubEvent.Channel()
	if err != nil {
		return
	}

	fmt.Println("Channel:", channel.Name())

}
Output:

Channel: someChannel

func (Event) Data

func (e Event) Data() ([]byte, error)

Data will get the data received with the pub-sub event returns a byte slice and an error

Example
package main

import (
	"fmt"

	symbols "github.com/taubyte/go-sdk-symbols/pubsub/event"
	"github.com/taubyte/go-sdk/event"

	_ "github.com/taubyte/go-sdk/pubsub/event"
)

func main() {
	// Mocking the calls to the vm for usage in tests and playground
	symbols.MockData{
		EventData: []byte("Hello, world!"),
	}.Mock()

	// An event that would be received by a taubyte function
	var e event.Event

	pubSubEvent, err := e.PubSub()
	if err != nil {
		return
	}

	data, err := pubSubEvent.Data()
	if err != nil {
		return
	}

	fmt.Println("Data:", string(data))

}
Output:

Data: Hello, world!

type EventMessage

type EventMessage uint32

Jump to

Keyboard shortcuts

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