prompting

package
v0.12.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2020 License: MIT Imports: 15 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_service_prompting_prompting_proto protoreflect.FileDescriptor

Functions

func Host added in v0.12.0

func Host(
	ctx context.Context, client PromptingClient,
	prompter prompting.Prompter, allowPrompts bool,
) (string, <-chan error, error)

Host is a utility function for hosting a prompter via the Prompting service's Host method. Although the Host method can be used directly, it requires complex interaction and most callers will simply want to host a prompter. Prompting is hosted in a background Goroutine. The identifier for the prompter is returned, as well as an error channel that will be populated with the first error to occur during prompting. Hosting will be terminated when either an error occurs or the provided context is cancelled. The error channel will be closed after hosting has terminated. If an error occurs during hosting setup, then it will be returned and hosting will not commence.

func RegisterPromptingServer

func RegisterPromptingServer(s *grpc.Server, srv PromptingServer)

Types

type HostRequest added in v0.12.0

type HostRequest struct {

	// AllowPrompts indicates whether or not the hoster will allow prompts. If
	// not, it will only receive message requests. This field may only be set on
	// the initial request.
	AllowPrompts bool `protobuf:"varint,1,opt,name=allowPrompts,proto3" json:"allowPrompts,omitempty"`
	// Response is the prompt response, if any. On the initial request, this
	// must be an empty string. When responding to a prompt, it may be any
	// value. When responding to a message, it must be an empty string.
	Response string `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"`
	// contains filtered or unexported fields
}

HostRequest encodes either an initial request to perform prompt hosting or a follow-up response to a message or prompt.

func (*HostRequest) Descriptor deprecated added in v0.12.0

func (*HostRequest) Descriptor() ([]byte, []int)

Deprecated: Use HostRequest.ProtoReflect.Descriptor instead.

func (*HostRequest) GetAllowPrompts added in v0.12.0

func (x *HostRequest) GetAllowPrompts() bool

func (*HostRequest) GetResponse added in v0.12.0

func (x *HostRequest) GetResponse() string

func (*HostRequest) ProtoMessage added in v0.12.0

func (*HostRequest) ProtoMessage()

func (*HostRequest) ProtoReflect added in v0.12.0

func (x *HostRequest) ProtoReflect() protoreflect.Message

func (*HostRequest) Reset added in v0.12.0

func (x *HostRequest) Reset()

func (*HostRequest) String added in v0.12.0

func (x *HostRequest) String() string

type HostResponse added in v0.12.0

type HostResponse struct {

	// Identifier is the prompter identifier. It is only set in the initial
	// response sent after the initial request.
	Identifier string `protobuf:"bytes,1,opt,name=identifier,proto3" json:"identifier,omitempty"`
	// IsPrompt indicates if the response is requesting a prompt (as opposed to
	// simple message display).
	IsPrompt bool `protobuf:"varint,2,opt,name=isPrompt,proto3" json:"isPrompt,omitempty"`
	// Message is the message associated with the prompt or message.
	Message string `protobuf:"bytes,3,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

HostResponse encodes either an initial response to perform prompt hosting or a follow-up request for messaging or prompting.

func (*HostResponse) Descriptor deprecated added in v0.12.0

func (*HostResponse) Descriptor() ([]byte, []int)

Deprecated: Use HostResponse.ProtoReflect.Descriptor instead.

func (*HostResponse) EnsureValid added in v0.12.0

func (r *HostResponse) EnsureValid(first, allowPrompts bool) error

EnsureValid verifies that a HostResponse is valid.

func (*HostResponse) GetIdentifier added in v0.12.0

func (x *HostResponse) GetIdentifier() string

func (*HostResponse) GetIsPrompt added in v0.12.0

func (x *HostResponse) GetIsPrompt() bool

func (*HostResponse) GetMessage added in v0.12.0

func (x *HostResponse) GetMessage() string

func (*HostResponse) ProtoMessage added in v0.12.0

func (*HostResponse) ProtoMessage()

func (*HostResponse) ProtoReflect added in v0.12.0

func (x *HostResponse) ProtoReflect() protoreflect.Message

func (*HostResponse) Reset added in v0.12.0

func (x *HostResponse) Reset()

func (*HostResponse) String added in v0.12.0

func (x *HostResponse) String() string

type PromptRequest

type PromptRequest struct {

	// Prompter is the prompter identifier.
	Prompter string `protobuf:"bytes,1,opt,name=prompter,proto3" json:"prompter,omitempty"`
	// Prompt is the prompt to present.
	Prompt string `protobuf:"bytes,2,opt,name=prompt,proto3" json:"prompt,omitempty"`
	// contains filtered or unexported fields
}

PromptRequest encodes a request for prompting by a specific prompter.

func (*PromptRequest) Descriptor deprecated

func (*PromptRequest) Descriptor() ([]byte, []int)

Deprecated: Use PromptRequest.ProtoReflect.Descriptor instead.

func (*PromptRequest) GetPrompt

func (x *PromptRequest) GetPrompt() string

func (*PromptRequest) GetPrompter

func (x *PromptRequest) GetPrompter() string

func (*PromptRequest) ProtoMessage

func (*PromptRequest) ProtoMessage()

func (*PromptRequest) ProtoReflect added in v0.12.0

func (x *PromptRequest) ProtoReflect() protoreflect.Message

func (*PromptRequest) Reset

func (x *PromptRequest) Reset()

func (*PromptRequest) String

func (x *PromptRequest) String() string

type PromptResponse

type PromptResponse struct {

	// Response is the response returned by the prompter.
	Response string `protobuf:"bytes,1,opt,name=response,proto3" json:"response,omitempty"`
	// contains filtered or unexported fields
}

PromptResponse encodes the response from a prompter.

func (*PromptResponse) Descriptor deprecated

func (*PromptResponse) Descriptor() ([]byte, []int)

Deprecated: Use PromptResponse.ProtoReflect.Descriptor instead.

func (*PromptResponse) EnsureValid

func (r *PromptResponse) EnsureValid() error

EnsureValid verifies that a PromptResponse is valid.

func (*PromptResponse) GetResponse

func (x *PromptResponse) GetResponse() string

func (*PromptResponse) ProtoMessage

func (*PromptResponse) ProtoMessage()

func (*PromptResponse) ProtoReflect added in v0.12.0

func (x *PromptResponse) ProtoReflect() protoreflect.Message

func (*PromptResponse) Reset

func (x *PromptResponse) Reset()

func (*PromptResponse) String

func (x *PromptResponse) String() string

type PromptingClient

type PromptingClient interface {
	// Host allows clients to perform prompt hosting.
	Host(ctx context.Context, opts ...grpc.CallOption) (Prompting_HostClient, error)
	// Prompt performs prompting using a specific prompter.
	Prompt(ctx context.Context, in *PromptRequest, opts ...grpc.CallOption) (*PromptResponse, error)
}

PromptingClient is the client API for Prompting service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.

func NewPromptingClient

func NewPromptingClient(cc grpc.ClientConnInterface) PromptingClient

type PromptingServer

type PromptingServer interface {
	// Host allows clients to perform prompt hosting.
	Host(Prompting_HostServer) error
	// Prompt performs prompting using a specific prompter.
	Prompt(context.Context, *PromptRequest) (*PromptResponse, error)
}

PromptingServer is the server API for Prompting service.

type Prompting_HostClient added in v0.12.0

type Prompting_HostClient interface {
	Send(*HostRequest) error
	Recv() (*HostResponse, error)
	grpc.ClientStream
}

type Prompting_HostServer added in v0.12.0

type Prompting_HostServer interface {
	Send(*HostResponse) error
	Recv() (*HostRequest, error)
	grpc.ServerStream
}

type Server

type Server struct{}

Server provides an implementation of the Prompting service.

func NewServer

func NewServer() *Server

NewServer creates a new prompt server.

func (*Server) Host added in v0.12.0

func (s *Server) Host(stream Prompting_HostServer) error

Host performs prompt hosting.

func (*Server) Prompt

func (s *Server) Prompt(ctx context.Context, request *PromptRequest) (*PromptResponse, error)

Prompt performs prompting against registered prompters.

type UnimplementedPromptingServer

type UnimplementedPromptingServer struct {
}

UnimplementedPromptingServer can be embedded to have forward compatible implementations.

func (*UnimplementedPromptingServer) Host added in v0.12.0

func (*UnimplementedPromptingServer) Prompt

Jump to

Keyboard shortcuts

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