Documentation ¶
Index ¶
- Constants
- Variables
- func DebugEventsHandler(w http.ResponseWriter, req *http.Request)
- func HTTPHandlerEventStream(w http.ResponseWriter, req *http.Request)
- func HTTPHandlerSend(w http.ResponseWriter, r *http.Request)
- func InitMux(mux *http.ServeMux)
- func MonitorNode(w *Mux, hc *http.Client, idhex *net.IPAddr) error
- func ParseMessage(data []byte, mtype int) (cmd string, meta map[string]string, outd []byte, end int)
- func Send(msgType string, meta ...string)
- func SendFrameLenBinary(con io.Writer, data ...[]byte) (int, error)
- func SubscribeHandler(res http.ResponseWriter, req *http.Request)
- type AckRequest
- func (*AckRequest) Descriptor() ([]byte, []int)
- func (m *AckRequest) GetMessageId() string
- func (m *AckRequest) Marshal() (dAtA []byte, err error)
- func (m *AckRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *AckRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*AckRequest) ProtoMessage()
- func (m *AckRequest) Reset()
- func (m *AckRequest) Size() (n int)
- func (m *AckRequest) String() string
- func (m *AckRequest) Unmarshal(dAtA []byte) error
- func (m *AckRequest) XXX_DiscardUnknown()
- func (m *AckRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *AckRequest) XXX_Merge(src proto.Message)
- func (m *AckRequest) XXX_Size() int
- func (m *AckRequest) XXX_Unmarshal(b []byte) error
- type AckResponse
- func (*AckResponse) Descriptor() ([]byte, []int)
- func (m *AckResponse) Marshal() (dAtA []byte, err error)
- func (m *AckResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *AckResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*AckResponse) ProtoMessage()
- func (m *AckResponse) Reset()
- func (m *AckResponse) Size() (n int)
- func (m *AckResponse) String() string
- func (m *AckResponse) Unmarshal(dAtA []byte) error
- func (m *AckResponse) XXX_DiscardUnknown()
- func (m *AckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *AckResponse) XXX_Merge(src proto.Message)
- func (m *AckResponse) XXX_Size() int
- func (m *AckResponse) XXX_Unmarshal(b []byte) error
- type Backoff
- type ChannelHandler
- type EventStreamConnection
- type Gateway
- type HandlerCallbackFunc
- type Message
- type MessageEnvelope
- func (*MessageEnvelope) Descriptor() ([]byte, []int)
- func (m *MessageEnvelope) GetContentEncoding() string
- func (m *MessageEnvelope) GetData() []byte
- func (m *MessageEnvelope) GetDh() []byte
- func (m *MessageEnvelope) GetMessageId() string
- func (m *MessageEnvelope) GetPush() string
- func (m *MessageEnvelope) GetSalt() []byte
- func (m *MessageEnvelope) GetSender() *Vapid
- func (m *MessageEnvelope) Marshal() (dAtA []byte, err error)
- func (m *MessageEnvelope) MarshalTo(dAtA []byte) (int, error)
- func (m *MessageEnvelope) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*MessageEnvelope) ProtoMessage()
- func (m *MessageEnvelope) Reset()
- func (m *MessageEnvelope) Size() (n int)
- func (m *MessageEnvelope) String() string
- func (m *MessageEnvelope) Unmarshal(dAtA []byte) error
- func (m *MessageEnvelope) XXX_DiscardUnknown()
- func (m *MessageEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *MessageEnvelope) XXX_Merge(src proto.Message)
- func (m *MessageEnvelope) XXX_Size() int
- func (m *MessageEnvelope) XXX_Unmarshal(b []byte) error
- type MessageHandler
- type Metric
- type MetricProvider
- type MonitorRequest
- func (*MonitorRequest) Descriptor() ([]byte, []int)
- func (m *MonitorRequest) GetAuthorization() string
- func (m *MonitorRequest) GetKey() string
- func (m *MonitorRequest) GetPushSet() string
- func (m *MonitorRequest) Marshal() (dAtA []byte, err error)
- func (m *MonitorRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *MonitorRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*MonitorRequest) ProtoMessage()
- func (m *MonitorRequest) Reset()
- func (m *MonitorRequest) Size() (n int)
- func (m *MonitorRequest) String() string
- func (m *MonitorRequest) Unmarshal(dAtA []byte) error
- func (m *MonitorRequest) XXX_DiscardUnknown()
- func (m *MonitorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *MonitorRequest) XXX_Merge(src proto.Message)
- func (m *MonitorRequest) XXX_Size() int
- func (m *MonitorRequest) XXX_Unmarshal(b []byte) error
- type MsgConnection
- type Mux
- func (mux *Mux) AddConnection(id string, cp *MsgConnection)
- func (mux *Mux) AddHandler(path string, cp MessageHandler)
- func (mux *Mux) HTTPUDS(w http.ResponseWriter, r *http.Request)
- func (mux *Mux) HandleMessageForNode(ev *Message) error
- func (mux *Mux) Send(msgType string, meta ...string) error
- func (mux *Mux) SendMessage(ev *Message) error
- type PushRequest
- func (*PushRequest) Descriptor() ([]byte, []int)
- func (m *PushRequest) GetContentEncoding() string
- func (m *PushRequest) GetData() []byte
- func (m *PushRequest) GetDh() string
- func (m *PushRequest) GetPush() string
- func (m *PushRequest) GetRespondAsync() bool
- func (m *PushRequest) GetSalt() string
- func (m *PushRequest) GetTopic() string
- func (m *PushRequest) GetTtl() int32
- func (m *PushRequest) GetUrgency() string
- func (m *PushRequest) Marshal() (dAtA []byte, err error)
- func (m *PushRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *PushRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*PushRequest) ProtoMessage()
- func (m *PushRequest) Reset()
- func (m *PushRequest) Size() (n int)
- func (m *PushRequest) String() string
- func (m *PushRequest) Unmarshal(dAtA []byte) error
- func (m *PushRequest) XXX_DiscardUnknown()
- func (m *PushRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PushRequest) XXX_Merge(src proto.Message)
- func (m *PushRequest) XXX_Size() int
- func (m *PushRequest) XXX_Unmarshal(b []byte) error
- type PushResponse
- func (*PushResponse) Descriptor() ([]byte, []int)
- func (m *PushResponse) GetMessageId() string
- func (m *PushResponse) GetPushReceipt() string
- func (m *PushResponse) Marshal() (dAtA []byte, err error)
- func (m *PushResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *PushResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*PushResponse) ProtoMessage()
- func (m *PushResponse) Reset()
- func (m *PushResponse) Size() (n int)
- func (m *PushResponse) String() string
- func (m *PushResponse) Unmarshal(dAtA []byte) error
- func (m *PushResponse) XXX_DiscardUnknown()
- func (m *PushResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PushResponse) XXX_Merge(src proto.Message)
- func (m *PushResponse) XXX_Size() int
- func (m *PushResponse) XXX_Unmarshal(b []byte) error
- type Receipt
- func (*Receipt) Descriptor() ([]byte, []int)
- func (m *Receipt) GetMessageId() string
- func (m *Receipt) Marshal() (dAtA []byte, err error)
- func (m *Receipt) MarshalTo(dAtA []byte) (int, error)
- func (m *Receipt) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Receipt) ProtoMessage()
- func (m *Receipt) Reset()
- func (m *Receipt) Size() (n int)
- func (m *Receipt) String() string
- func (m *Receipt) Unmarshal(dAtA []byte) error
- func (m *Receipt) XXX_DiscardUnknown()
- func (m *Receipt) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Receipt) XXX_Merge(src proto.Message)
- func (m *Receipt) XXX_Size() int
- func (m *Receipt) XXX_Unmarshal(b []byte) error
- type ReceiptRequest
- func (*ReceiptRequest) Descriptor() ([]byte, []int)
- func (m *ReceiptRequest) GetReceiptSubscription() string
- func (m *ReceiptRequest) Marshal() (dAtA []byte, err error)
- func (m *ReceiptRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *ReceiptRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*ReceiptRequest) ProtoMessage()
- func (m *ReceiptRequest) Reset()
- func (m *ReceiptRequest) Size() (n int)
- func (m *ReceiptRequest) String() string
- func (m *ReceiptRequest) Unmarshal(dAtA []byte) error
- func (m *ReceiptRequest) XXX_DiscardUnknown()
- func (m *ReceiptRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ReceiptRequest) XXX_Merge(src proto.Message)
- func (m *ReceiptRequest) XXX_Size() int
- func (m *ReceiptRequest) XXX_Unmarshal(b []byte) error
- type Stream
- type SubscribeRequest
- func (*SubscribeRequest) Descriptor() ([]byte, []int)
- func (m *SubscribeRequest) GetPushSet() string
- func (m *SubscribeRequest) GetSenderVapid() string
- func (m *SubscribeRequest) Marshal() (dAtA []byte, err error)
- func (m *SubscribeRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *SubscribeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*SubscribeRequest) ProtoMessage()
- func (m *SubscribeRequest) Reset()
- func (m *SubscribeRequest) Size() (n int)
- func (m *SubscribeRequest) String() string
- func (m *SubscribeRequest) Unmarshal(dAtA []byte) error
- func (m *SubscribeRequest) XXX_DiscardUnknown()
- func (m *SubscribeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *SubscribeRequest) XXX_Merge(src proto.Message)
- func (m *SubscribeRequest) XXX_Size() int
- func (m *SubscribeRequest) XXX_Unmarshal(b []byte) error
- type SubscribeResponse
- func (*SubscribeResponse) Descriptor() ([]byte, []int)
- func (m *SubscribeResponse) GetLocation() string
- func (m *SubscribeResponse) GetPush() string
- func (m *SubscribeResponse) GetPushSet() string
- func (m *SubscribeResponse) Marshal() (dAtA []byte, err error)
- func (m *SubscribeResponse) MarshalTo(dAtA []byte) (int, error)
- func (m *SubscribeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*SubscribeResponse) ProtoMessage()
- func (m *SubscribeResponse) Reset()
- func (m *SubscribeResponse) Size() (n int)
- func (m *SubscribeResponse) String() string
- func (m *SubscribeResponse) Unmarshal(dAtA []byte) error
- func (m *SubscribeResponse) XXX_DiscardUnknown()
- func (m *SubscribeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *SubscribeResponse) XXX_Merge(src proto.Message)
- func (m *SubscribeResponse) XXX_Size() int
- func (m *SubscribeResponse) XXX_Unmarshal(b []byte) error
- type UA
- type Vapid
- func (*Vapid) Descriptor() ([]byte, []int)
- func (m *Vapid) GetData() []byte
- func (m *Vapid) GetK() []byte
- func (m *Vapid) GetSignatureX() []byte
- func (m *Vapid) GetSignatureY() []byte
- func (m *Vapid) GetTSignature() []byte
- func (m *Vapid) GetTType() []byte
- func (m *Vapid) Marshal() (dAtA []byte, err error)
- func (m *Vapid) MarshalTo(dAtA []byte) (int, error)
- func (m *Vapid) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*Vapid) ProtoMessage()
- func (m *Vapid) Reset()
- func (m *Vapid) Size() (n int)
- func (m *Vapid) String() string
- func (m *Vapid) Unmarshal(dAtA []byte) error
- func (m *Vapid) XXX_DiscardUnknown()
- func (m *Vapid) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *Vapid) XXX_Merge(src proto.Message)
- func (m *Vapid) XXX_Size() int
- func (m *Vapid) XXX_Unmarshal(b []byte) error
Constants ¶
const EV_BUFFER = 200
TODO: circular buffer, poll event, for debug
Variables ¶
var ( ErrInvalidLengthWebpush = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowWebpush = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupWebpush = fmt.Errorf("proto: unexpected end of group") )
var Debug = false
var DefaultMux = NewMux()
var ReceiveBaseUrl = "https://127.0.0.1:5228/"
Functions ¶
func DebugEventsHandler ¶
func DebugEventsHandler(w http.ResponseWriter, req *http.Request)
Return the sticky and recent events.
func HTTPHandlerEventStream ¶
func HTTPHandlerEventStream(w http.ResponseWriter, req *http.Request)
Used to receive (subscribe) to messages, using HTTP streaming protocol.
TODO: pass the list of subscriptions, filter, 'start' message
func HTTPHandlerSend ¶
func HTTPHandlerSend(w http.ResponseWriter, r *http.Request)
Used to push a message from a remote sender.
Mapped to /msg/
q or path can be used to pass command. Body and query string are sent. TODO: compatibility with cloud events and webpush TODO: RBAC (including admin check for system notifications)
func InitMux ¶
Mux corresponds to a server with TLS certificates. MTLS is optional, can be used instead of VAPID tokens.
func ParseMessage ¶
func ParseMessage(data []byte, mtype int) (cmd string, meta map[string]string, outd []byte, end int)
Parse a message. Currently used in the UDS mapping, using a HTTP1-like text format
func Send ¶
Send a message to the default mux. Will serialize the event and save it for debugging.
Local handlers and debug tools/admin can subscribe.
func SendFrameLenBinary ¶
Send a binary packet, with len prefix. Currently used in the UDS mapping.
func SubscribeHandler ¶
func SubscribeHandler(res http.ResponseWriter, req *http.Request)
Subscribe creates a subscription. Initial version is just a random - some interface will be added later, to allow sets.
Types ¶
type AckRequest ¶
type AckRequest struct {
MessageId string `protobuf:"bytes,1,opt,name=message_id,proto3" json:"message_id,omitempty"`
}
func (*AckRequest) Descriptor ¶
func (*AckRequest) Descriptor() ([]byte, []int)
func (*AckRequest) GetMessageId ¶
func (m *AckRequest) GetMessageId() string
func (*AckRequest) Marshal ¶
func (m *AckRequest) Marshal() (dAtA []byte, err error)
func (*AckRequest) MarshalToSizedBuffer ¶
func (m *AckRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*AckRequest) ProtoMessage ¶
func (*AckRequest) ProtoMessage()
func (*AckRequest) Reset ¶
func (m *AckRequest) Reset()
func (*AckRequest) Size ¶
func (m *AckRequest) Size() (n int)
func (*AckRequest) String ¶
func (m *AckRequest) String() string
func (*AckRequest) Unmarshal ¶
func (m *AckRequest) Unmarshal(dAtA []byte) error
func (*AckRequest) XXX_DiscardUnknown ¶
func (m *AckRequest) XXX_DiscardUnknown()
func (*AckRequest) XXX_Marshal ¶
func (m *AckRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*AckRequest) XXX_Merge ¶
func (m *AckRequest) XXX_Merge(src proto.Message)
func (*AckRequest) XXX_Size ¶
func (m *AckRequest) XXX_Size() int
func (*AckRequest) XXX_Unmarshal ¶
func (m *AckRequest) XXX_Unmarshal(b []byte) error
type AckResponse ¶
type AckResponse struct { }
func (*AckResponse) Descriptor ¶
func (*AckResponse) Descriptor() ([]byte, []int)
func (*AckResponse) Marshal ¶
func (m *AckResponse) Marshal() (dAtA []byte, err error)
func (*AckResponse) MarshalToSizedBuffer ¶
func (m *AckResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*AckResponse) ProtoMessage ¶
func (*AckResponse) ProtoMessage()
func (*AckResponse) Reset ¶
func (m *AckResponse) Reset()
func (*AckResponse) Size ¶
func (m *AckResponse) Size() (n int)
func (*AckResponse) String ¶
func (m *AckResponse) String() string
func (*AckResponse) Unmarshal ¶
func (m *AckResponse) Unmarshal(dAtA []byte) error
func (*AckResponse) XXX_DiscardUnknown ¶
func (m *AckResponse) XXX_DiscardUnknown()
func (*AckResponse) XXX_Marshal ¶
func (m *AckResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*AckResponse) XXX_Merge ¶
func (m *AckResponse) XXX_Merge(src proto.Message)
func (*AckResponse) XXX_Size ¶
func (m *AckResponse) XXX_Size() int
func (*AckResponse) XXX_Unmarshal ¶
func (m *AckResponse) XXX_Unmarshal(b []byte) error
type ChannelHandler ¶
type ChannelHandler struct {
MsgChan chan *Message
}
func NewChannelHandler ¶
func NewChannelHandler() *ChannelHandler
func (*ChannelHandler) HandleMessage ¶
func (*ChannelHandler) WaitEvent ¶
func (u *ChannelHandler) WaitEvent(name string) *Message
type EventStreamConnection ¶
type EventStreamConnection struct {
MsgConnection
}
type Gateway ¶
type Gateway struct { // technically we could handle multiple mux and ids in a gateway - but // not clear use case (besides tests) NodeId string // contains filtered or unexported fields }
Gateway handles the incoming and outgoing connections, and adaptation between protocols. Messages for local pod are handled by Mux.
func (*Gateway) OnRemoteMessage ¶
Message from a remote, will be forwarded to subscribed connections.
func (*Gateway) RemoveConnection ¶
func (gate *Gateway) RemoveConnection(id string, cp *MsgConnection)
type HandlerCallbackFunc ¶
type HandlerCallbackFunc func(ctx context.Context, cmdS string, meta map[string]string, data []byte)
Adapter from func to interface
func (HandlerCallbackFunc) HandleMessage ¶
func (f HandlerCallbackFunc) HandleMessage(ctx context.Context, cmdS string, meta map[string]string, data []byte)
ServeHTTP calls f(w, r).
type Message ¶
type Message struct { //RFC3339 "2018-04-05T17:31:00Z" Time string `json:"time,omitempty"` // ID of event, to dedup. Id string `json:"id,omitempty"` // Can be 'topic', or destination To string `json:"to,omitempty"` Subject string `json:"subject,omitempty"` // VIPs in the path Path []string `json:"path,omitempty"` // Describes the event producer - VIP or public key From string `json:"from,omitempty"` // JSON-serializable payload. // Interface means will be serialized as base64 if []byte, as String if string or actual Json without encouding // otherwise. Data interface{} `json:"data,omitempty"` // TS is the timestamp, in go format. When sending over the wire, converted to Time. From time when received. TS time.Time `json:"-"` // If data is a map (common case) Meta map[string]string `json:"meta,omitempty"` // If received from a remote, the connection it was received on. // nil if generated locally Connection *MsgConnection `json:"-"` // Extracted from To URL Topic string `json:"-"` }
Records recent received messages and broadcasts, for debug and UI
func (*Message) Binary ¶
Return a binary representation of the data: either the []byte for raw data, or the marshalled json starting with {.
func (*Message) MarshalJSON ¶
func (*Message) SetDataJSON ¶
type MessageEnvelope ¶
type MessageEnvelope struct { MessageId string `protobuf:"bytes,1,opt,name=message_id,proto3" json:"message_id,omitempty"` // Maps to the SubscribeResponse push parameter, returned as Link rel="urn:ietf:params:push" // in the push promise. Push string `protobuf:"bytes,2,opt,name=push,proto3" json:"push,omitempty"` // If 'dh' and 'salt' are set, will contain encrypted data. Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // Identifies the sender. Sender *Vapid `protobuf:"bytes,4,opt,name=sender,proto3" json:"sender,omitempty"` ContentEncoding string `protobuf:"bytes,7,opt,name=content_encoding,proto3" json:"content_encoding,omitempty"` Salt []byte `protobuf:"bytes,8,opt,name=salt,proto3" json:"salt,omitempty"` Dh []byte `protobuf:"bytes,9,opt,name=dh,proto3" json:"dh,omitempty"` }
Message is returned as PUSH PROMISE frames in the spec. The alternative protocol wraps it in Any field or other framing.
func (*MessageEnvelope) Descriptor ¶
func (*MessageEnvelope) Descriptor() ([]byte, []int)
func (*MessageEnvelope) GetContentEncoding ¶
func (m *MessageEnvelope) GetContentEncoding() string
func (*MessageEnvelope) GetData ¶
func (m *MessageEnvelope) GetData() []byte
func (*MessageEnvelope) GetDh ¶
func (m *MessageEnvelope) GetDh() []byte
func (*MessageEnvelope) GetMessageId ¶
func (m *MessageEnvelope) GetMessageId() string
func (*MessageEnvelope) GetPush ¶
func (m *MessageEnvelope) GetPush() string
func (*MessageEnvelope) GetSalt ¶
func (m *MessageEnvelope) GetSalt() []byte
func (*MessageEnvelope) GetSender ¶
func (m *MessageEnvelope) GetSender() *Vapid
func (*MessageEnvelope) Marshal ¶
func (m *MessageEnvelope) Marshal() (dAtA []byte, err error)
func (*MessageEnvelope) MarshalToSizedBuffer ¶
func (m *MessageEnvelope) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*MessageEnvelope) ProtoMessage ¶
func (*MessageEnvelope) ProtoMessage()
func (*MessageEnvelope) Reset ¶
func (m *MessageEnvelope) Reset()
func (*MessageEnvelope) Size ¶
func (m *MessageEnvelope) Size() (n int)
func (*MessageEnvelope) String ¶
func (m *MessageEnvelope) String() string
func (*MessageEnvelope) Unmarshal ¶
func (m *MessageEnvelope) Unmarshal(dAtA []byte) error
func (*MessageEnvelope) XXX_DiscardUnknown ¶
func (m *MessageEnvelope) XXX_DiscardUnknown()
func (*MessageEnvelope) XXX_Marshal ¶
func (m *MessageEnvelope) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*MessageEnvelope) XXX_Merge ¶
func (m *MessageEnvelope) XXX_Merge(src proto.Message)
func (*MessageEnvelope) XXX_Size ¶
func (m *MessageEnvelope) XXX_Size() int
func (*MessageEnvelope) XXX_Unmarshal ¶
func (m *MessageEnvelope) XXX_Unmarshal(b []byte) error
type MessageHandler ¶
type MessageHandler interface { // Handle a message. Context may provide access to the actual message object // and mux. HandleMessage(ctx context.Context, cmdS string, meta map[string]string, data []byte) }
Local processing of messages. Interface doesn't use any specific struct, to avoid creating deps.
type Metric ¶
type Metric interface {
Add(float64)
}
Metric is an interface for applications updating metrics Expvar is an interface between metric and the collection system.
type MetricProvider ¶
type MonitorRequest ¶
type MonitorRequest struct { // This is the push or push_set in the subscribe response. PushSet string `protobuf:"bytes,1,opt,name=push_set,proto3" json:"push_set,omitempty"` // JWT token, signed with key Authorization string `protobuf:"bytes,2,opt,name=authorization,proto3" json:"authorization,omitempty"` // Public key used for signing, identifies sender/receiver Key string `protobuf:"bytes,3,opt,name=key,proto3" json:"key,omitempty"` }
func (*MonitorRequest) Descriptor ¶
func (*MonitorRequest) Descriptor() ([]byte, []int)
func (*MonitorRequest) GetAuthorization ¶
func (m *MonitorRequest) GetAuthorization() string
func (*MonitorRequest) GetKey ¶
func (m *MonitorRequest) GetKey() string
func (*MonitorRequest) GetPushSet ¶
func (m *MonitorRequest) GetPushSet() string
func (*MonitorRequest) Marshal ¶
func (m *MonitorRequest) Marshal() (dAtA []byte, err error)
func (*MonitorRequest) MarshalToSizedBuffer ¶
func (m *MonitorRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*MonitorRequest) ProtoMessage ¶
func (*MonitorRequest) ProtoMessage()
func (*MonitorRequest) Reset ¶
func (m *MonitorRequest) Reset()
func (*MonitorRequest) Size ¶
func (m *MonitorRequest) Size() (n int)
func (*MonitorRequest) String ¶
func (m *MonitorRequest) String() string
func (*MonitorRequest) Unmarshal ¶
func (m *MonitorRequest) Unmarshal(dAtA []byte) error
func (*MonitorRequest) XXX_DiscardUnknown ¶
func (m *MonitorRequest) XXX_DiscardUnknown()
func (*MonitorRequest) XXX_Marshal ¶
func (m *MonitorRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*MonitorRequest) XXX_Merge ¶
func (m *MonitorRequest) XXX_Merge(src proto.Message)
func (*MonitorRequest) XXX_Size ¶
func (m *MonitorRequest) XXX_Size() int
func (*MonitorRequest) XXX_Unmarshal ¶
func (m *MonitorRequest) XXX_Unmarshal(b []byte) error
type MsgConnection ¶
type MsgConnection struct { // Key used in mux to track this connection Name string // Broadcast subscriptions to forward to the remote. Will have a 'From' set to current node. // VPN and upstream server use "*" to receive/pass up all events. // TODO: keep some messages local, by using To=., and indicate broadcasts as *. SubscriptionsToSend []string // OnMessage is called when a message for this connection is dispatched. // The message should be either a broadcast, have as To the vip of the connection or // another vip reachable from the connection. // // The topic of the message should be in the Subscription list if the destination is this vip. // // Internal handlers may use the same interface. SendMessageToRemote func(ev *Message) error // contains filtered or unexported fields }
One connection - incoming or outgoing. Can send messages to the remote end, which may in turn forward messages for other nodes.
Incoming messages are dispatched to the mux, which may deliver locally or forward.
func (*MsgConnection) Close ¶
func (mc *MsgConnection) Close()
func (*MsgConnection) HandleMessageStream ¶
func (mconn *MsgConnection) HandleMessageStream(cb func(message *Message), br *bufio.Reader, from string, self string)
Messages received from remote, over SSH.
from is the authenticated VIP of the sender. self is my own VIP
type Mux ¶
type Mux struct { Gate *Gateway // contains filtered or unexported fields }
Mux handles processing messages for this node, and sending messages from local code.
func (*Mux) AddConnection ¶
func (mux *Mux) AddConnection(id string, cp *MsgConnection)
id - remote id. "uds" for the primary upstream uds connection to host (android app or wifi/root app)
func (*Mux) AddHandler ¶
func (mux *Mux) AddHandler(path string, cp MessageHandler)
Add a local handler for a specific message type or * This is a local function.
func (*Mux) HTTPUDS ¶
func (mux *Mux) HTTPUDS(w http.ResponseWriter, r *http.Request)
Currently mapped to /dmesh/uds - sends a message to a specific connection, defaults to the UDS connection to the android or root dmwifi app.
func (*Mux) HandleMessageForNode ¶
Called for local events (host==. or empty). Called when a message is received from one of the local streams ( UDS, etc ), if the final destination is the current node.
Message will be passed to one or more of the local handlers, based on type.
TODO: authorization (based on identity of the caller)
func (*Mux) SendMessage ¶
Publish a message. Will be distributed to remote listeners. TODO: routing for directed messages (to specific destination) TODO: up/down indication for multicast, subscription
type PushRequest ¶
type PushRequest struct { // The value returned in the SubscribeResponse push, without the hostname. Push string `protobuf:"bytes,1,opt,name=push,proto3" json:"push,omitempty"` Ttl int32 `protobuf:"varint,2,opt,name=ttl,proto3" json:"ttl,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` Urgency string `protobuf:"bytes,4,opt,name=urgency,proto3" json:"urgency,omitempty"` // Prefer header indicating delivery receipt request. RespondAsync bool `protobuf:"varint,5,opt,name=respond_async,proto3" json:"respond_async,omitempty"` Topic string `protobuf:"bytes,6,opt,name=topic,proto3" json:"topic,omitempty"` ContentEncoding string `protobuf:"bytes,7,opt,name=content_encoding,proto3" json:"content_encoding,omitempty"` Salt string `protobuf:"bytes,8,opt,name=salt,proto3" json:"salt,omitempty"` Dh string `protobuf:"bytes,9,opt,name=dh,proto3" json:"dh,omitempty"` }
func (*PushRequest) Descriptor ¶
func (*PushRequest) Descriptor() ([]byte, []int)
func (*PushRequest) GetContentEncoding ¶
func (m *PushRequest) GetContentEncoding() string
func (*PushRequest) GetData ¶
func (m *PushRequest) GetData() []byte
func (*PushRequest) GetDh ¶
func (m *PushRequest) GetDh() string
func (*PushRequest) GetPush ¶
func (m *PushRequest) GetPush() string
func (*PushRequest) GetRespondAsync ¶
func (m *PushRequest) GetRespondAsync() bool
func (*PushRequest) GetSalt ¶
func (m *PushRequest) GetSalt() string
func (*PushRequest) GetTopic ¶
func (m *PushRequest) GetTopic() string
func (*PushRequest) GetTtl ¶
func (m *PushRequest) GetTtl() int32
func (*PushRequest) GetUrgency ¶
func (m *PushRequest) GetUrgency() string
func (*PushRequest) Marshal ¶
func (m *PushRequest) Marshal() (dAtA []byte, err error)
func (*PushRequest) MarshalToSizedBuffer ¶
func (m *PushRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*PushRequest) ProtoMessage ¶
func (*PushRequest) ProtoMessage()
func (*PushRequest) Reset ¶
func (m *PushRequest) Reset()
func (*PushRequest) Size ¶
func (m *PushRequest) Size() (n int)
func (*PushRequest) String ¶
func (m *PushRequest) String() string
func (*PushRequest) Unmarshal ¶
func (m *PushRequest) Unmarshal(dAtA []byte) error
func (*PushRequest) XXX_DiscardUnknown ¶
func (m *PushRequest) XXX_DiscardUnknown()
func (*PushRequest) XXX_Marshal ¶
func (m *PushRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PushRequest) XXX_Merge ¶
func (m *PushRequest) XXX_Merge(src proto.Message)
func (*PushRequest) XXX_Size ¶
func (m *PushRequest) XXX_Size() int
func (*PushRequest) XXX_Unmarshal ¶
func (m *PushRequest) XXX_Unmarshal(b []byte) error
type PushResponse ¶
type PushResponse struct { MessageId string `protobuf:"bytes,1,opt,name=message_id,proto3" json:"message_id,omitempty"` // If request includes the respond_async parameter. // PushReceipt string `protobuf:"bytes,2,opt,name=push_receipt,proto3" json:"push_receipt,omitempty"` }
func (*PushResponse) Descriptor ¶
func (*PushResponse) Descriptor() ([]byte, []int)
func (*PushResponse) GetMessageId ¶
func (m *PushResponse) GetMessageId() string
func (*PushResponse) GetPushReceipt ¶
func (m *PushResponse) GetPushReceipt() string
func (*PushResponse) Marshal ¶
func (m *PushResponse) Marshal() (dAtA []byte, err error)
func (*PushResponse) MarshalToSizedBuffer ¶
func (m *PushResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*PushResponse) ProtoMessage ¶
func (*PushResponse) ProtoMessage()
func (*PushResponse) Reset ¶
func (m *PushResponse) Reset()
func (*PushResponse) Size ¶
func (m *PushResponse) Size() (n int)
func (*PushResponse) String ¶
func (m *PushResponse) String() string
func (*PushResponse) Unmarshal ¶
func (m *PushResponse) Unmarshal(dAtA []byte) error
func (*PushResponse) XXX_DiscardUnknown ¶
func (m *PushResponse) XXX_DiscardUnknown()
func (*PushResponse) XXX_Marshal ¶
func (m *PushResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PushResponse) XXX_Merge ¶
func (m *PushResponse) XXX_Merge(src proto.Message)
func (*PushResponse) XXX_Size ¶
func (m *PushResponse) XXX_Size() int
func (*PushResponse) XXX_Unmarshal ¶
func (m *PushResponse) XXX_Unmarshal(b []byte) error
type Receipt ¶
type Receipt struct {
MessageId string `protobuf:"bytes,1,opt,name=message_id,proto3" json:"message_id,omitempty"`
}
func (*Receipt) Descriptor ¶
func (*Receipt) GetMessageId ¶
func (*Receipt) MarshalToSizedBuffer ¶
func (*Receipt) ProtoMessage ¶
func (*Receipt) ProtoMessage()
func (*Receipt) XXX_DiscardUnknown ¶
func (m *Receipt) XXX_DiscardUnknown()
func (*Receipt) XXX_Marshal ¶
func (*Receipt) XXX_Unmarshal ¶
type ReceiptRequest ¶
type ReceiptRequest struct {
ReceiptSubscription string `protobuf:"bytes,1,opt,name=receipt_subscription,proto3" json:"receipt_subscription,omitempty"`
}
func (*ReceiptRequest) Descriptor ¶
func (*ReceiptRequest) Descriptor() ([]byte, []int)
func (*ReceiptRequest) GetReceiptSubscription ¶
func (m *ReceiptRequest) GetReceiptSubscription() string
func (*ReceiptRequest) Marshal ¶
func (m *ReceiptRequest) Marshal() (dAtA []byte, err error)
func (*ReceiptRequest) MarshalToSizedBuffer ¶
func (m *ReceiptRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*ReceiptRequest) ProtoMessage ¶
func (*ReceiptRequest) ProtoMessage()
func (*ReceiptRequest) Reset ¶
func (m *ReceiptRequest) Reset()
func (*ReceiptRequest) Size ¶
func (m *ReceiptRequest) Size() (n int)
func (*ReceiptRequest) String ¶
func (m *ReceiptRequest) String() string
func (*ReceiptRequest) Unmarshal ¶
func (m *ReceiptRequest) Unmarshal(dAtA []byte) error
func (*ReceiptRequest) XXX_DiscardUnknown ¶
func (m *ReceiptRequest) XXX_DiscardUnknown()
func (*ReceiptRequest) XXX_Marshal ¶
func (m *ReceiptRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ReceiptRequest) XXX_Merge ¶
func (m *ReceiptRequest) XXX_Merge(src proto.Message)
func (*ReceiptRequest) XXX_Size ¶
func (m *ReceiptRequest) XXX_Size() int
func (*ReceiptRequest) XXX_Unmarshal ¶
func (m *ReceiptRequest) XXX_Unmarshal(b []byte) error
type SubscribeRequest ¶
type SubscribeRequest struct { // A UA should group subscriptions in a set. First request from a // UA will not include a set - it is typically a subscription associated with // the UA itself. PushSet string `protobuf:"bytes,1,opt,name=push_set,proto3" json:"push_set,omitempty"` // Included as Crypto-Key: p256ecdsa parameter. // Corresponds to the applicationServerKey parameter in the PushSubscriptionOptions in // the W3C API SenderVapid string `protobuf:"bytes,2,opt,name=sender_vapid,proto3" json:"sender_vapid,omitempty"` }
func (*SubscribeRequest) Descriptor ¶
func (*SubscribeRequest) Descriptor() ([]byte, []int)
func (*SubscribeRequest) GetPushSet ¶
func (m *SubscribeRequest) GetPushSet() string
func (*SubscribeRequest) GetSenderVapid ¶
func (m *SubscribeRequest) GetSenderVapid() string
func (*SubscribeRequest) Marshal ¶
func (m *SubscribeRequest) Marshal() (dAtA []byte, err error)
func (*SubscribeRequest) MarshalToSizedBuffer ¶
func (m *SubscribeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*SubscribeRequest) ProtoMessage ¶
func (*SubscribeRequest) ProtoMessage()
func (*SubscribeRequest) Reset ¶
func (m *SubscribeRequest) Reset()
func (*SubscribeRequest) Size ¶
func (m *SubscribeRequest) Size() (n int)
func (*SubscribeRequest) String ¶
func (m *SubscribeRequest) String() string
func (*SubscribeRequest) Unmarshal ¶
func (m *SubscribeRequest) Unmarshal(dAtA []byte) error
func (*SubscribeRequest) XXX_DiscardUnknown ¶
func (m *SubscribeRequest) XXX_DiscardUnknown()
func (*SubscribeRequest) XXX_Marshal ¶
func (m *SubscribeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*SubscribeRequest) XXX_Merge ¶
func (m *SubscribeRequest) XXX_Merge(src proto.Message)
func (*SubscribeRequest) XXX_Size ¶
func (m *SubscribeRequest) XXX_Size() int
func (*SubscribeRequest) XXX_Unmarshal ¶
func (m *SubscribeRequest) XXX_Unmarshal(b []byte) error
type SubscribeResponse ¶
type SubscribeResponse struct { // Returned as Link: rel="urn:ietf:params:push" // Spec examples use a full path ( /push/xxxx1 ) // TODO: clarify if it can be a full URL Push string `protobuf:"bytes,1,opt,name=push,proto3" json:"push,omitempty"` // Optional response: it // returned as Link: rel=urn:ietf:params:push:set // Spec examples use a full path ( /subscription-set/xxxx2 ). // TODO: clarify it can be a full URL, like subscription PushSet string `protobuf:"bytes,2,opt,name=push_set,proto3" json:"push_set,omitempty"` // Push subscription resource. This is the full URL where the UA will use to // receive the messages, using the PUSH promise http2 frame. // // // Returned as Location header in the spec Location string `protobuf:"bytes,3,opt,name=location,proto3" json:"location,omitempty"` }
Subscribe response includes the elements in the spec.
func (*SubscribeResponse) Descriptor ¶
func (*SubscribeResponse) Descriptor() ([]byte, []int)
func (*SubscribeResponse) GetLocation ¶
func (m *SubscribeResponse) GetLocation() string
func (*SubscribeResponse) GetPush ¶
func (m *SubscribeResponse) GetPush() string
func (*SubscribeResponse) GetPushSet ¶
func (m *SubscribeResponse) GetPushSet() string
func (*SubscribeResponse) Marshal ¶
func (m *SubscribeResponse) Marshal() (dAtA []byte, err error)
func (*SubscribeResponse) MarshalTo ¶
func (m *SubscribeResponse) MarshalTo(dAtA []byte) (int, error)
func (*SubscribeResponse) MarshalToSizedBuffer ¶
func (m *SubscribeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*SubscribeResponse) ProtoMessage ¶
func (*SubscribeResponse) ProtoMessage()
func (*SubscribeResponse) Reset ¶
func (m *SubscribeResponse) Reset()
func (*SubscribeResponse) Size ¶
func (m *SubscribeResponse) Size() (n int)
func (*SubscribeResponse) String ¶
func (m *SubscribeResponse) String() string
func (*SubscribeResponse) Unmarshal ¶
func (m *SubscribeResponse) Unmarshal(dAtA []byte) error
func (*SubscribeResponse) XXX_DiscardUnknown ¶
func (m *SubscribeResponse) XXX_DiscardUnknown()
func (*SubscribeResponse) XXX_Marshal ¶
func (m *SubscribeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*SubscribeResponse) XXX_Merge ¶
func (m *SubscribeResponse) XXX_Merge(src proto.Message)
func (*SubscribeResponse) XXX_Size ¶
func (m *SubscribeResponse) XXX_Size() int
func (*SubscribeResponse) XXX_Unmarshal ¶
func (m *SubscribeResponse) XXX_Unmarshal(b []byte) error
type UA ¶
type UA struct { // URL of the subscribe for the push service PushService string }
UA represents a "user agent" - or client using the webpush protocol
type Vapid ¶
type Vapid struct { // json payload of VAPID ( without base64 encoding) // Can also be a proto message when used over other transports. Data []byte `protobuf:"bytes,7,opt,name=data,proto3" json:"data,omitempty"` // Public key of the signer, 64 bytes, EC256. // Included in 'k' parameter for HTTP. K []byte `protobuf:"bytes,4,opt,name=k,proto3" json:"k,omitempty"` // If empty, it is assumed to be the constant value {typ=JWT,alg=ES256} TType []byte `protobuf:"bytes,32,opt,name=t_type,proto3" json:"t_type,omitempty"` // If empty, signatureX and signatureY will be used, with the constant prefix // This reduces the size of the packet when in binary - verification is still over // JSON format TSignature []byte `protobuf:"bytes,33,opt,name=t_signature,proto3" json:"t_signature,omitempty"` SignatureX []byte `protobuf:"bytes,5,opt,name=signatureX,proto3" json:"signatureX,omitempty"` SignatureY []byte `protobuf:"bytes,6,opt,name=signatureY,proto3" json:"signatureY,omitempty"` }
Vapid is the proto variant of a Webpush JWT.
For HTTP, included in Authorization header: Authorization: vapid t=B64url k=B64url
Decoded t is of form: { "typ": "JWT", "alg": "ES256" }
{ "crv":"P-256",
"kty":"EC", "x":"DUfHPKLVFQzVvnCPGyfucbECzPDa7rWbXriLcysAjEc", "y":"F6YK5h4SDYic-dRuU_RCPCfA5aq9ojSwk5Y2EmClBPs" }
func (*Vapid) Descriptor ¶
func (*Vapid) GetSignatureX ¶
func (*Vapid) GetSignatureY ¶
func (*Vapid) GetTSignature ¶
func (*Vapid) ProtoMessage ¶
func (*Vapid) ProtoMessage()
func (*Vapid) XXX_DiscardUnknown ¶
func (m *Vapid) XXX_DiscardUnknown()