dstest

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 14 Imported by: 0

README

dstest

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDatastoreServer

func NewDatastoreServer(t *testing.T) (_ *grpc.ClientConn, _ *mockServer, _ func())

func PageBounds

func PageBounds(pageSize int, pageToken string, length int) (from, to int, nextPageToken string, err error)

PageBounds converts an incoming page size and token from an RPC request into slice bounds and the outgoing next-page token.

PageBounds assumes that the complete, unpaginated list of items exists as a single slice. In addition to the page size and token, PageBounds needs the length of that slice.

PageBounds's first two return values should be used to construct a sub-slice of the complete, unpaginated slice. E.g. if the complete slice is s, then s[from:to] is the desired page. Its third return value should be set as the NextPageToken field of the RPC response.

Types

type Server

type Server struct {
	Addr string
	Port int

	Gsrv *grpc.Server
	// contains filtered or unexported fields
}
srv, err := NewServer()
...
mypb.RegisterMyServiceServer(srv.Gsrv, &myHandler)
....
srv.Start()

Clients should connect to the server with no security:

conn, err := grpc.Dial(srv.Addr, grpc.WithInsecure())
...

func NewServer

func NewServer(opts ...grpc.ServerOption) (*Server, error)

NewServer creates a new Server. The Server will be listening for gRPC connections at the address named by the Addr field, without TLS.

func NewServerWithPort

func NewServerWithPort(port int, opts ...grpc.ServerOption) (*Server, error)

NewServerWithPort creates a new Server at a specific port. The Server will be listening for gRPC connections at the address named by the Addr field, without TLS.

func (*Server) Close

func (s *Server) Close()

Close shuts down the server.

func (*Server) Start

func (s *Server) Start()

Start causes the server to start accepting incoming connections. Call Start after registering handlers.

Jump to

Keyboard shortcuts

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