Documentation ¶
Overview ¶
Package proto contains protocol buffers for gRPC pushpull event ingestion and delivery system.
Using gRPC client ¶
## Push example:
package main import ( "context" "fmt" "os" "time" "google.golang.org/grpc" "google.golang.org/grpc/keepalive" "github.com/vardius/pushpull/proto" ) func main() { host:= "0.0.0.0" port:= 9090 ctx := context.Background() opts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 10 * time.Second, // send pings every 10 seconds if there is no activity Timeout: 20 * time.Second, // wait 20 second for ping ack before considering the connection dead PermitWithoutStream: true, // send pings even without active streams }), } conn, err := grpc.DialContext(ctx, fmt.Sprintf("%s:%d", host, port), opts...) if err != nil { os.Exit(1) } defer conn.Close() client := proto.NewPushPullClient(conn) client.Push(ctx, &proto.PublishRequest{ Topic: "my-topic", Payload: []byte("Hello you!"), }) }
## Pull example:
package main import ( "context" "fmt" "os" "time" "google.golang.org/grpc" "google.golang.org/grpc/keepalive" "github.com/vardius/pushpull/proto" ) func main() { host:= "0.0.0.0" port:= 9090 ctx := context.Background() opts := []grpc.DialOption{ grpc.WithInsecure(), grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: 10 * time.Second, // send pings every 10 seconds if there is no activity Timeout: 20 * time.Second, // wait 20 second for ping ack before considering the connection dead PermitWithoutStream: true, // send pings even without active streams }), } conn, err := grpc.DialContext(ctx, fmt.Sprintf("%s:%d", host, port), opts...) if err != nil { os.Exit(1) } defer conn.Close() client := proto.NewPushPullClient(conn) stream, err := client.Pull(ctx, &proto.SubscribeRequest{ Topic: "my-topic", }) if err != nil { os.Exit(1) } for { resp, err := stream.Recv() if err != nil { os.Exit(1) // stream closed or error } fmt.Println(resp.GetPayload()) } }
Index ¶
- func RegisterPushPullServer(s *grpc.Server, srv PushPullServer)
- type PullRequest
- func (*PullRequest) Descriptor() ([]byte, []int)
- func (m *PullRequest) GetTopic() string
- func (*PullRequest) ProtoMessage()
- func (m *PullRequest) Reset()
- func (m *PullRequest) String() string
- func (m *PullRequest) XXX_DiscardUnknown()
- func (m *PullRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PullRequest) XXX_Merge(src proto.Message)
- func (m *PullRequest) XXX_Size() int
- func (m *PullRequest) XXX_Unmarshal(b []byte) error
- type PullResponse
- func (*PullResponse) Descriptor() ([]byte, []int)
- func (m *PullResponse) GetPayload() []byte
- func (*PullResponse) ProtoMessage()
- func (m *PullResponse) Reset()
- func (m *PullResponse) String() string
- func (m *PullResponse) XXX_DiscardUnknown()
- func (m *PullResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *PullResponse) XXX_Merge(src proto.Message)
- func (m *PullResponse) XXX_Size() int
- func (m *PullResponse) XXX_Unmarshal(b []byte) error
- type PushPullClient
- type PushPullServer
- type PushPull_PullClient
- type PushPull_PullServer
- type PushRequest
- func (*PushRequest) Descriptor() ([]byte, []int)
- func (m *PushRequest) GetPayload() []byte
- func (m *PushRequest) GetTopic() string
- func (*PushRequest) ProtoMessage()
- func (m *PushRequest) Reset()
- func (m *PushRequest) String() string
- 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 UnimplementedPushPullServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterPushPullServer ¶
func RegisterPushPullServer(s *grpc.Server, srv PushPullServer)
Types ¶
type PullRequest ¶
type PullRequest struct { Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
PullRequest is passed when listing for new event in queue
func (*PullRequest) Descriptor ¶
func (*PullRequest) Descriptor() ([]byte, []int)
func (*PullRequest) GetTopic ¶
func (m *PullRequest) GetTopic() string
func (*PullRequest) ProtoMessage ¶
func (*PullRequest) ProtoMessage()
func (*PullRequest) Reset ¶
func (m *PullRequest) Reset()
func (*PullRequest) String ¶
func (m *PullRequest) String() string
func (*PullRequest) XXX_DiscardUnknown ¶
func (m *PullRequest) XXX_DiscardUnknown()
func (*PullRequest) XXX_Marshal ¶
func (m *PullRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PullRequest) XXX_Merge ¶
func (m *PullRequest) XXX_Merge(src proto.Message)
func (*PullRequest) XXX_Size ¶
func (m *PullRequest) XXX_Size() int
func (*PullRequest) XXX_Unmarshal ¶
func (m *PullRequest) XXX_Unmarshal(b []byte) error
type PullResponse ¶
type PullResponse struct { Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
PullResponse object
func (*PullResponse) Descriptor ¶
func (*PullResponse) Descriptor() ([]byte, []int)
func (*PullResponse) GetPayload ¶
func (m *PullResponse) GetPayload() []byte
func (*PullResponse) ProtoMessage ¶
func (*PullResponse) ProtoMessage()
func (*PullResponse) Reset ¶
func (m *PullResponse) Reset()
func (*PullResponse) String ¶
func (m *PullResponse) String() string
func (*PullResponse) XXX_DiscardUnknown ¶
func (m *PullResponse) XXX_DiscardUnknown()
func (*PullResponse) XXX_Marshal ¶
func (m *PullResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*PullResponse) XXX_Merge ¶
func (m *PullResponse) XXX_Merge(src proto.Message)
func (*PullResponse) XXX_Size ¶
func (m *PullResponse) XXX_Size() int
func (*PullResponse) XXX_Unmarshal ¶
func (m *PullResponse) XXX_Unmarshal(b []byte) error
type PushPullClient ¶
type PushPullClient interface { Push(ctx context.Context, in *PushRequest, opts ...grpc.CallOption) (*empty.Empty, error) Pull(ctx context.Context, in *PullRequest, opts ...grpc.CallOption) (PushPull_PullClient, error) }
PushPullClient is the client API for PushPull service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewPushPullClient ¶
func NewPushPullClient(cc grpc.ClientConnInterface) PushPullClient
type PushPullServer ¶
type PushPullServer interface { Push(context.Context, *PushRequest) (*empty.Empty, error) Pull(*PullRequest, PushPull_PullServer) error }
PushPullServer is the server API for PushPull service.
type PushPull_PullClient ¶
type PushPull_PullClient interface { Recv() (*PullResponse, error) grpc.ClientStream }
type PushPull_PullServer ¶
type PushPull_PullServer interface { Send(*PullResponse) error grpc.ServerStream }
type PushRequest ¶
type PushRequest struct { Topic string `protobuf:"bytes,1,opt,name=topic,proto3" json:"topic,omitempty"` Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
PushRequest is passed when pushing to the queue
func (*PushRequest) Descriptor ¶
func (*PushRequest) Descriptor() ([]byte, []int)
func (*PushRequest) GetPayload ¶
func (m *PushRequest) GetPayload() []byte
func (*PushRequest) GetTopic ¶
func (m *PushRequest) GetTopic() string
func (*PushRequest) ProtoMessage ¶
func (*PushRequest) ProtoMessage()
func (*PushRequest) Reset ¶
func (m *PushRequest) Reset()
func (*PushRequest) String ¶
func (m *PushRequest) String() string
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 UnimplementedPushPullServer ¶
type UnimplementedPushPullServer struct { }
UnimplementedPushPullServer can be embedded to have forward compatible implementations.
func (*UnimplementedPushPullServer) Pull ¶
func (*UnimplementedPushPullServer) Pull(req *PullRequest, srv PushPull_PullServer) error
func (*UnimplementedPushPullServer) Push ¶
func (*UnimplementedPushPullServer) Push(ctx context.Context, req *PushRequest) (*empty.Empty, error)
Click to show internal directories.
Click to hide internal directories.