backwards_invocation

package
v0.0.0-...-e06565c Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InvokeDify

func InvokeDify(
	declaration *plugin_entities.PluginDeclaration,
	invoke_from access_types.PluginAccessType,
	session *session_manager.Session,
	writer BackwardsInvocationWriter,
	data []byte,
) error

returns error only if payload is not correct

Types

type BackwardsInvocation

type BackwardsInvocation struct {
	// contains filtered or unexported fields
}

BackwardsInvocation is a struct that represents a backwards invocation For different plugin runtime type, stream handler is different

  1. Local and Remote: they are both full duplex, multiplexing could be implemented by different session different session share the same physical channel.
  2. AWS: it is half duplex, one request could have multiple channels, we need to combine them into one stream

That's why it has a writer, for different transaction, the writer is unique

func NewBackwardsInvocation

func NewBackwardsInvocation(
	typ BackwardsInvocationType,
	id string,
	session *session_manager.Session,
	writer BackwardsInvocationWriter,
	detailedRequest map[string]any,
) *BackwardsInvocation

func (*BackwardsInvocation) EndResponse

func (bi *BackwardsInvocation) EndResponse()

func (*BackwardsInvocation) GetID

func (bi *BackwardsInvocation) GetID() string

func (*BackwardsInvocation) RequestData

func (bi *BackwardsInvocation) RequestData() map[string]any

func (*BackwardsInvocation) TenantID

func (bi *BackwardsInvocation) TenantID() (string, error)

func (*BackwardsInvocation) Type

func (*BackwardsInvocation) UserID

func (bi *BackwardsInvocation) UserID() (string, error)

func (*BackwardsInvocation) WriteError

func (bi *BackwardsInvocation) WriteError(err error)

func (*BackwardsInvocation) WriteResponse

func (bi *BackwardsInvocation) WriteResponse(message string, data any)

type BackwardsInvocationResponseEvent

type BackwardsInvocationResponseEvent struct {
	BackwardsRequestId string       `json:"backwards_request_id"`
	Event              RequestEvent `json:"event"`
	Message            string       `json:"message"`
	Data               any          `json:"data"`
}

func NewEndEvent

func NewEndEvent(request_id string) *BackwardsInvocationResponseEvent

func NewErrorEvent

func NewErrorEvent(request_id string, message string) *BackwardsInvocationResponseEvent

func NewResponseEvent

func NewResponseEvent(request_id string, message string, data any) *BackwardsInvocationResponseEvent

type BackwardsInvocationType

type BackwardsInvocationType = dify_invocation.InvokeType

type BackwardsInvocationWriter

type BackwardsInvocationWriter interface {
	Write(event session_manager.PLUGIN_IN_STREAM_EVENT, data any) error
	Done()
}

type RequestEvent

type RequestEvent string
const (
	REQUEST_EVENT_RESPONSE RequestEvent = "response"
	REQUEST_EVENT_ERROR    RequestEvent = "error"
	REQUEST_EVENT_END      RequestEvent = "end"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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