Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ozanmakes/inngestgo

 
 

Repository files navigation

GoDoc

Inngest Go SDK

A simple SDK for sending well-formed events to Inngest.

Example usage:

Using a dedicated client as a dependency:

import (
	"context"
	"os"

	"github.com/inngest/inngestgo"
)

func sendEvent(ctx context.Context) {
	// Create a new client
	client := inngestgo.NewClient(os.Getenv("INGEST_KEY"))

	// Send an event
	client.Send(ctx, inngestgo.Event{
		Name: "user.created",
		Data: map[string]interface{}{
			"plan": account.PlanType,
			"ip":   req.RemoteAddr,
		},
		User: map[string]interface{}{
			// Use the external_id field within User so that we can identify
			// this event as authored by the given user.
			inngestgo.ExternalID: user.ID,
			inngestgo.Email:      ou.Email,
		},
		Version:   "2021-07-01.01",
		Timestamp: inngestgo.Now(),
	})
}

Using the default client, so that any package can call inngestgo.Send:

import (
	"context"
	"os"

	"github.com/inngest/inngestgo"
)

func init() {
	// Set the default client.
	inngestgo.DefaultClient = inngestgo.NewClient(os.Getenv("INGEST_KEY"))
}

func do() {
	// Now, we can use inngestgo.Send(ctx, evt) to send using the
	// default client.  This reduces the need for you to pass the
	// inngest client down as a dependency for each package.
	inngestgo.Send(ctx, inngestgo.Event{
		Name: "user.created",
		Data: map[string]interface{}{
			"plan": account.PlanType,
			"ip":   req.RemoteAddr,
		},
		User: map[string]interface{}{
			// Use the external_id field within User so that we can identify
			// this event as authored by the given user.
			inngestgo.ExternalID: user.ID,
			inngestgo.Email:      ou.Email,
		},
		Version:   "2021-07-01.01",
		Timestamp: inngestgo.Now(),
	})
}

About

Golang SDK for sending events to Inngest

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 99.4%
  • Other 0.6%