Documentation ¶
Index ¶
- Variables
- func DefaultSubjectForAgentFunc(agentID string) string
- func NewResponseWriter(transport responseSender) http.ResponseWriter
- func SerializeMap(m map[string][]string) map[string]*Values
- func SetupConnOptions(opts []nats.Option) []nats.Option
- func UnserializeMap(m map[string]*Values) map[string][]string
- type Agent
- type AgentResponseBroker
- type HTTPProxy
- type RandomSuffix
- type RandomSuffixGetter
- type Request
- func (*Request) Descriptor() ([]byte, []int)deprecated
- func (x *Request) GetBody() []byte
- func (x *Request) GetForm() map[string]*Values
- func (x *Request) GetHeader() map[string]*Values
- func (x *Request) GetMethod() string
- func (x *Request) GetRemoteAddr() string
- func (x *Request) GetTransportInfo() *TransportInfo
- func (x *Request) GetURL() string
- func (*Request) ProtoMessage()
- func (x *Request) ProtoReflect() protoreflect.Message
- func (x *Request) Reset()
- func (x *Request) String() string
- type Response
- func (*Response) Descriptor() ([]byte, []int)deprecated
- func (x *Response) GetBody() []byte
- func (x *Response) GetDoUpgrade() bool
- func (x *Response) GetHeader() map[string]*Values
- func (x *Response) GetStatusCode() int32
- func (x *Response) GetTransportInfo() *TransportInfo
- func (*Response) ProtoMessage()
- func (x *Response) ProtoReflect() protoreflect.Message
- func (x *Response) Reset()
- func (x *Response) String() string
- type ResponseWriter
- type SubjectForAgentFunc
- type TransportInfo
- func (*TransportInfo) Descriptor() ([]byte, []int)deprecated
- func (x *TransportInfo) GetClosing() bool
- func (x *TransportInfo) GetKeepAlive() bool
- func (x *TransportInfo) GetSequence() int32
- func (*TransportInfo) ProtoMessage()
- func (x *TransportInfo) ProtoReflect() protoreflect.Message
- func (x *TransportInfo) Reset()
- func (x *TransportInfo) String() string
- type Tunnel
- type Values
Constants ¶
This section is empty.
Variables ¶
var File_http_proto protoreflect.FileDescriptor
Functions ¶
func DefaultSubjectForAgentFunc ¶
DefaultSubjectForAgentFunc returns the default NATS subject for a given agent
func NewResponseWriter ¶
func NewResponseWriter(transport responseSender) http.ResponseWriter
NewResponseWriter returns an instance of ResponseWriter
func SerializeMap ¶
SerializeMap converts golang map to protobuf map.
func SetupConnOptions ¶
func SetupConnOptions(opts []nats.Option) []nats.Option
SetupConnOptions sets up defaults for nats connection
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent listens for incoming proxy requests for a given agent.
func NewAgent ¶
func NewAgent(nc *nats.Conn, id uuid.UUID, handler http.Handler, subject string, keepAliveInterval time.Duration) *Agent
NewAgent will connect to nats in main cluster and proxy connections locally to an http.Handler. TODO: add reasonable defaults for keepAliveInterval
func (*Agent) Drain ¶
Drain de-registers interest in all subscriptions and drains connections to gracefully shut down.
func (*Agent) IsDraining ¶
IsDraining verifies the state of Drain on the nats connection
type AgentResponseBroker ¶
type AgentResponseBroker struct {
// contains filtered or unexported fields
}
AgentResponseBroker that brokers the nats messages stream generated by AgentResponseWriter back into an http response, use NewAgentResponseBroker to initialize.
func NewAgentResponseBroker ¶
func NewAgentResponseBroker(w http.ResponseWriter) *AgentResponseBroker
NewAgentResponseBroker returns an initialized AgentResponseBroker that brokers the nats messages stream generated by AgentResponseWriter back into an http response.
type HTTPProxy ¶
type HTTPProxy struct {
// contains filtered or unexported fields
}
HTTPProxy proxies http requests through nats to a remote agent
func NewHTTPProxy ¶
NewHTTPProxy returns an instance that proxies http requests through nats to a remote agent
type RandomSuffix ¶
type RandomSuffix struct {
// contains filtered or unexported fields
}
RandomSuffix will generate a random suffix for use in Nats Msg.reply field.
type RandomSuffixGetter ¶
type RandomSuffixGetter interface {
Get() string
}
RandomSuffixGetter defines interface get a random suffix for a nats message.
type Request ¶
type Request struct { TransportInfo *TransportInfo `protobuf:"bytes,1,opt,name=transportInfo,proto3" json:"transportInfo,omitempty"` URL string `protobuf:"bytes,2,opt,name=URL,proto3" json:"URL,omitempty"` Method string `protobuf:"bytes,3,opt,name=Method,proto3" json:"Method,omitempty"` RemoteAddr string `protobuf:"bytes,4,opt,name=RemoteAddr,proto3" json:"RemoteAddr,omitempty"` Body []byte `protobuf:"bytes,5,opt,name=Body,proto3" json:"Body,omitempty"` Form map[string]*Values `` /* 149-byte string literal not displayed */ Header map[string]*Values `` /* 153-byte string literal not displayed */ // contains filtered or unexported fields }
func (*Request) Descriptor
deprecated
func (*Request) GetRemoteAddr ¶
func (*Request) GetTransportInfo ¶
func (x *Request) GetTransportInfo() *TransportInfo
func (*Request) ProtoMessage ¶
func (*Request) ProtoMessage()
func (*Request) ProtoReflect ¶
func (x *Request) ProtoReflect() protoreflect.Message
type Response ¶
type Response struct { TransportInfo *TransportInfo `protobuf:"bytes,1,opt,name=transportInfo,proto3" json:"transportInfo,omitempty"` StatusCode int32 `protobuf:"varint,2,opt,name=StatusCode,proto3" json:"StatusCode,omitempty"` Header map[string]*Values `` /* 153-byte string literal not displayed */ Body []byte `protobuf:"bytes,4,opt,name=Body,proto3" json:"Body,omitempty"` DoUpgrade bool `protobuf:"varint,5,opt,name=DoUpgrade,proto3" json:"DoUpgrade,omitempty"` // contains filtered or unexported fields }
func (*Response) Descriptor
deprecated
func (*Response) GetDoUpgrade ¶
func (*Response) GetStatusCode ¶
func (*Response) GetTransportInfo ¶
func (x *Response) GetTransportInfo() *TransportInfo
func (*Response) ProtoMessage ¶
func (*Response) ProtoMessage()
func (*Response) ProtoReflect ¶
func (x *Response) ProtoReflect() protoreflect.Message
type ResponseWriter ¶
ResponseWriter serializes and writes http responses over nats as part of Agent.
func (*ResponseWriter) Flush ¶
func (rw *ResponseWriter) Flush()
Flush does nothing, but conforms to flusher interface to maintain interoperable behavior with the previous proxy that is still in use.
func (*ResponseWriter) Header ¶
func (rw *ResponseWriter) Header() http.Header
Header returns the header map of the Response
func (*ResponseWriter) Write ¶
func (rw *ResponseWriter) Write(p []byte) (n int, err error)
Write will write bytes to body of the response. If headers have not been written this will write headers.
func (*ResponseWriter) WriteHeader ¶
func (rw *ResponseWriter) WriteHeader(code int)
WriteHeader writes the http code and headers to output.
type SubjectForAgentFunc ¶
SubjectForAgentFunc is function to obtains NATS subject for a given agent ID
type TransportInfo ¶
type TransportInfo struct { Sequence int32 `protobuf:"varint,1,opt,name=Sequence,proto3" json:"Sequence,omitempty"` KeepAlive bool `protobuf:"varint,2,opt,name=KeepAlive,proto3" json:"KeepAlive,omitempty"` Closing bool `protobuf:"varint,3,opt,name=Closing,proto3" json:"Closing,omitempty"` // contains filtered or unexported fields }
func (*TransportInfo) Descriptor
deprecated
func (*TransportInfo) Descriptor() ([]byte, []int)
Deprecated: Use TransportInfo.ProtoReflect.Descriptor instead.
func (*TransportInfo) GetClosing ¶
func (x *TransportInfo) GetClosing() bool
func (*TransportInfo) GetKeepAlive ¶
func (x *TransportInfo) GetKeepAlive() bool
func (*TransportInfo) GetSequence ¶
func (x *TransportInfo) GetSequence() int32
func (*TransportInfo) ProtoMessage ¶
func (*TransportInfo) ProtoMessage()
func (*TransportInfo) ProtoReflect ¶
func (x *TransportInfo) ProtoReflect() protoreflect.Message
func (*TransportInfo) Reset ¶
func (x *TransportInfo) Reset()
func (*TransportInfo) String ¶
func (x *TransportInfo) String() string
type Tunnel ¶
type Tunnel struct {
// contains filtered or unexported fields
}
Tunnel creates a request that expects 1..n replies from a remote nats client
type Values ¶
type Values struct { Arr []string `protobuf:"bytes,1,rep,name=arr,proto3" json:"arr,omitempty"` // contains filtered or unexported fields }
func (*Values) Descriptor
deprecated
func (*Values) ProtoMessage ¶
func (*Values) ProtoMessage()
func (*Values) ProtoReflect ¶
func (x *Values) ProtoReflect() protoreflect.Message