flight

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, + 8 more Imports: 25 Imported by: 0

Documentation

Overview

Example (Server)
// Licensed to the Apache Software Foundation (ASF) under one
// or more contributor license agreements.  See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership.  The ASF licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License.  You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package main

import (
	"context"
	"fmt"
	"io"
	"log"

	"github.com/aliyun/aliyun-odps-go-sdk/arrow/flight"
	"google.golang.org/grpc"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/status"
)

type serverAuth struct{}

func (sa *serverAuth) Authenticate(c flight.AuthConn) error {
	in, err := c.Read()
	if err == io.EOF {
		return status.Error(codes.Unauthenticated, "no auth info provided")
	}

	if err != nil {
		return status.Error(codes.FailedPrecondition, "error reading auth handshake")
	}

	// do something with in....
	fmt.Println(string(in))

	// send auth token back
	return c.Send([]byte("foobar"))
}

func (sa *serverAuth) IsValid(token string) (interface{}, error) {
	if token == "foobar" {
		return "foo", nil
	}
	return "", status.Error(codes.PermissionDenied, "invalid auth token")
}

func main() {
	server := flight.NewFlightServer(&serverAuth{})
	server.Init("localhost:0")
	server.RegisterFlightService(&flight.FlightServiceService{})

	go server.Serve()
	defer server.Shutdown()

	conn, err := grpc.Dial(server.Addr().String(), grpc.WithInsecure())
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	client := flight.NewFlightServiceClient(conn)
	stream, err := client.Handshake(context.Background())
	if err != nil {
		log.Fatal(err)
	}

	// ignore error handling here for brevity
	stream.Send(&flight.HandshakeRequest{Payload: []byte("baz")})

	resp, _ := stream.Recv()
	fmt.Println(string(resp.Payload))

}
Output:

baz
foobar

Index

Examples

Constants

This section is empty.

Variables

View Source
var (
	FlightDescriptor_DescriptorType_name = map[int32]string{
		0: "UNKNOWN",
		1: "PATH",
		2: "CMD",
	}
	FlightDescriptor_DescriptorType_value = map[string]int32{
		"UNKNOWN": 0,
		"PATH":    1,
		"CMD":     2,
	}
)

Enum value maps for FlightDescriptor_DescriptorType.

View Source
var File_Flight_proto protoreflect.FileDescriptor

Functions

func AuthFromContext

func AuthFromContext(ctx context.Context) interface{}

AuthFromContext will return back whatever object was returned from `IsValid` for a given request context allowing handlers to retrieve identifying information for the current request for use.

func CreateServerBearerTokenAuthInterceptors deprecated

func CreateServerBearerTokenAuthInterceptors(validator BasicAuthValidator) (grpc.UnaryServerInterceptor, grpc.StreamServerInterceptor)

CreateServerBearerTokenAuthInterceptors returns grpc interceptors for basic auth handling via bearer tokens. validator cannot be nil

Deprecated: use CreateServerBasicAuthMiddleware instead

func DeserializeSchema

func DeserializeSchema(info []byte, mem memory.Allocator) (*arrow.Schema, error)

DeserializeSchema takes the schema bytes from FlightInfo or SchemaResult and returns the deserialized arrow schema.

func RegisterFlightServiceService

func RegisterFlightServiceService(s grpc.ServiceRegistrar, srv *FlightServiceService)

RegisterFlightServiceService registers a service implementation with a gRPC server.

func SerializeSchema

func SerializeSchema(rec *arrow.Schema, mem memory.Allocator) []byte

SerializeSchema returns the serialized schema bytes for use in Arrow Flight protobuf messages.

Types

type Action

type Action struct {
	Type string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	Body []byte `protobuf:"bytes,2,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

An opaque action specific for the service.

func (*Action) Descriptor deprecated

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

Deprecated: Use Action.ProtoReflect.Descriptor instead.

func (*Action) GetBody

func (x *Action) GetBody() []byte

func (*Action) GetType

func (x *Action) GetType() string

func (*Action) ProtoMessage

func (*Action) ProtoMessage()

func (*Action) ProtoReflect

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

func (*Action) Reset

func (x *Action) Reset()

func (*Action) String

func (x *Action) String() string

type ActionType

type ActionType struct {
	Type        string `protobuf:"bytes,1,opt,name=type,proto3" json:"type,omitempty"`
	Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"`
	// contains filtered or unexported fields
}

Describes an available action, including both the name used for execution along with a short description of the purpose of the action.

func (*ActionType) Descriptor deprecated

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

Deprecated: Use ActionType.ProtoReflect.Descriptor instead.

func (*ActionType) GetDescription

func (x *ActionType) GetDescription() string

func (*ActionType) GetType

func (x *ActionType) GetType() string

func (*ActionType) ProtoMessage

func (*ActionType) ProtoMessage()

func (*ActionType) ProtoReflect

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

func (*ActionType) Reset

func (x *ActionType) Reset()

func (*ActionType) String

func (x *ActionType) String() string

type AuthConn

type AuthConn interface {
	Read() ([]byte, error)
	Send([]byte) error
}

AuthConn wraps the stream from grpc for handshakes to simplify handling handshake request and response from the flight.proto forwarding just the payloads and errors instead of having to deal with the handshake request and response protos directly

type BasicAuth

type BasicAuth struct {
	Username string `protobuf:"bytes,2,opt,name=username,proto3" json:"username,omitempty"`
	Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"`
	// contains filtered or unexported fields
}

A message for doing simple auth.

func (*BasicAuth) Descriptor deprecated

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

Deprecated: Use BasicAuth.ProtoReflect.Descriptor instead.

func (*BasicAuth) GetPassword

func (x *BasicAuth) GetPassword() string

func (*BasicAuth) GetUsername

func (x *BasicAuth) GetUsername() string

func (*BasicAuth) ProtoMessage

func (*BasicAuth) ProtoMessage()

func (*BasicAuth) ProtoReflect

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

func (*BasicAuth) Reset

func (x *BasicAuth) Reset()

func (*BasicAuth) String

func (x *BasicAuth) String() string

type BasicAuthValidator

type BasicAuthValidator interface {
	Validate(username, password string) (string, error)
	IsValid(bearerToken string) (interface{}, error)
}

type Client

type Client interface {
	// Authenticate uses the ClientAuthHandler that was used when creating the client
	// in order to use the Handshake endpoints of the service.
	Authenticate(context.Context, ...grpc.CallOption) error
	AuthenticateBasicToken(ctx context.Context, username string, password string, opts ...grpc.CallOption) (context.Context, error)
	Close() error
	// join the interface from the FlightServiceClient instead of re-defining all
	// the endpoints here.
	FlightServiceClient
}

Client is an interface wrapped around the generated FlightServiceClient which is generated by grpc protobuf definitions. This interface provides a useful hiding of the authentication handshake via calling Authenticate and using the ClientAuthHandler rather than manually having to implement the grpc communication and sending of the auth token.

func NewClientWithMiddleware

func NewClientWithMiddleware(addr string, auth ClientAuthHandler, middleware []ClientMiddleware, opts ...grpc.DialOption) (Client, error)

NewClientWithMiddleware takes a slice of middlewares in addition to the auth and address which will be used by grpc and chained, the first middleware will be the outer most with the last middleware being the inner most wrapper around the actual call. It also passes along the dialoptions passed in such as TLS certs and so on.

func NewFlightClient deprecated

func NewFlightClient(addr string, auth ClientAuthHandler, opts ...grpc.DialOption) (Client, error)

NewFlightClient takes in the address of the grpc server and an auth handler for the application-level handshake. If using TLS or other grpc configurations they can still be passed via the grpc.DialOption list just as if connecting manually without this helper function.

Alternatively, a grpc client can be constructed as normal without this helper as the grpc generated client code is still exported. This exists to add utility and helpers around the authentication and passing the token with requests.

Deprecated: prefer to use NewClientWithMiddleware

type ClientAuthHandler

type ClientAuthHandler interface {
	Authenticate(context.Context, AuthConn) error
	GetToken(context.Context) (string, error)
}

ClientAuthHandler defines an interface for the Flight client to perform the authentication handshake. The token that is retrieved from GetToken will be sent as part of the context metadata in subsequent requests after authentication is performed using the key "auth-token-bin".

type ClientHeadersMiddleware

type ClientHeadersMiddleware interface {
	HeadersReceived(ctx context.Context, md metadata.MD)
}

type ClientMiddleware

type ClientMiddleware struct {
	Stream grpc.StreamClientInterceptor
	Unary  grpc.UnaryClientInterceptor
}

func CreateClientMiddleware

func CreateClientMiddleware(middleware CustomClientMiddleware) ClientMiddleware

type ClientPostCallMiddleware

type ClientPostCallMiddleware interface {
	CallCompleted(ctx context.Context, err error)
}

type Criteria

type Criteria struct {
	Expression []byte `protobuf:"bytes,1,opt,name=expression,proto3" json:"expression,omitempty"`
	// contains filtered or unexported fields
}

A service specific expression that can be used to return a limited set of available Arrow Flight streams.

func (*Criteria) Descriptor deprecated

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

Deprecated: Use Criteria.ProtoReflect.Descriptor instead.

func (*Criteria) GetExpression

func (x *Criteria) GetExpression() []byte

func (*Criteria) ProtoMessage

func (*Criteria) ProtoMessage()

func (*Criteria) ProtoReflect

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

func (*Criteria) Reset

func (x *Criteria) Reset()

func (*Criteria) String

func (x *Criteria) String() string

type CustomClientMiddleware

type CustomClientMiddleware interface {
	StartCall(ctx context.Context) context.Context
}

type CustomServerMiddleware

type CustomServerMiddleware interface {
	// StartCall will be called with the current context of the call, grpc.SetHeader can be used to add outgoing headers
	// if the returned context is non-nil, then it will be used as the new context being passed through the calls
	StartCall(ctx context.Context) context.Context
	// CallCompleted is a callback which is called with the return from the handler
	// it will be nil if everything was successful or will be the error about to be returned
	// to grpc
	CallCompleted(ctx context.Context, err error)
}

type DataStreamReader

type DataStreamReader interface {
	Recv() (*FlightData, error)
}

DataStreamReader is an interface for receiving flight data messages on a stream such as via grpc with Arrow Flight.

type DataStreamWriter

type DataStreamWriter interface {
	Send(*FlightData) error
}

DataStreamWriter is an interface that represents an Arrow Flight stream writer that writes FlightData objects

type Empty

type Empty struct {
	// contains filtered or unexported fields
}

func (*Empty) Descriptor deprecated

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

Deprecated: Use Empty.ProtoReflect.Descriptor instead.

func (*Empty) ProtoMessage

func (*Empty) ProtoMessage()

func (*Empty) ProtoReflect

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

func (*Empty) Reset

func (x *Empty) Reset()

func (*Empty) String

func (x *Empty) String() string

type FlightData

type FlightData struct {

	//
	// The descriptor of the data. This is only relevant when a client is
	// starting a new DoPut stream.
	FlightDescriptor *FlightDescriptor `protobuf:"bytes,1,opt,name=flight_descriptor,json=flightDescriptor,proto3" json:"flight_descriptor,omitempty"`
	//
	// Header for message data as described in Message.fbs::Message.
	DataHeader []byte `protobuf:"bytes,2,opt,name=data_header,json=dataHeader,proto3" json:"data_header,omitempty"`
	//
	// Application-defined metadata.
	AppMetadata []byte `protobuf:"bytes,3,opt,name=app_metadata,json=appMetadata,proto3" json:"app_metadata,omitempty"`
	//
	// The actual batch of Arrow data. Preferably handled with minimal-copies
	// coming last in the definition to help with sidecar patterns (it is
	// expected that some implementations will fetch this field off the wire
	// with specialized code to avoid extra memory copies).
	DataBody []byte `protobuf:"bytes,1000,opt,name=data_body,json=dataBody,proto3" json:"data_body,omitempty"`
	// contains filtered or unexported fields
}

A batch of Arrow data as part of a stream of batches.

func (*FlightData) Descriptor deprecated

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

Deprecated: Use FlightData.ProtoReflect.Descriptor instead.

func (*FlightData) GetAppMetadata

func (x *FlightData) GetAppMetadata() []byte

func (*FlightData) GetDataBody

func (x *FlightData) GetDataBody() []byte

func (*FlightData) GetDataHeader

func (x *FlightData) GetDataHeader() []byte

func (*FlightData) GetFlightDescriptor

func (x *FlightData) GetFlightDescriptor() *FlightDescriptor

func (*FlightData) ProtoMessage

func (*FlightData) ProtoMessage()

func (*FlightData) ProtoReflect

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

func (*FlightData) Reset

func (x *FlightData) Reset()

func (*FlightData) String

func (x *FlightData) String() string

type FlightDescriptor

type FlightDescriptor struct {
	Type FlightDescriptor_DescriptorType `protobuf:"varint,1,opt,name=type,proto3,enum=arrow.flight.protocol.FlightDescriptor_DescriptorType" json:"type,omitempty"`
	//
	// Opaque value used to express a command. Should only be defined when
	// type = CMD.
	Cmd []byte `protobuf:"bytes,2,opt,name=cmd,proto3" json:"cmd,omitempty"`
	//
	// List of strings identifying a particular dataset. Should only be defined
	// when type = PATH.
	Path []string `protobuf:"bytes,3,rep,name=path,proto3" json:"path,omitempty"`
	// contains filtered or unexported fields
}

The name or tag for a Flight. May be used as a way to retrieve or generate a flight or be used to expose a set of previously defined flights.

func (*FlightDescriptor) Descriptor deprecated

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

Deprecated: Use FlightDescriptor.ProtoReflect.Descriptor instead.

func (*FlightDescriptor) GetCmd

func (x *FlightDescriptor) GetCmd() []byte

func (*FlightDescriptor) GetPath

func (x *FlightDescriptor) GetPath() []string

func (*FlightDescriptor) GetType

func (*FlightDescriptor) ProtoMessage

func (*FlightDescriptor) ProtoMessage()

func (*FlightDescriptor) ProtoReflect

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

func (*FlightDescriptor) Reset

func (x *FlightDescriptor) Reset()

func (*FlightDescriptor) String

func (x *FlightDescriptor) String() string

type FlightDescriptor_DescriptorType

type FlightDescriptor_DescriptorType int32

Describes what type of descriptor is defined.

const (
	// Protobuf pattern, not used.
	FlightDescriptor_UNKNOWN FlightDescriptor_DescriptorType = 0
	//
	// A named path that identifies a dataset. A path is composed of a string
	// or list of strings describing a particular dataset. This is conceptually
	//  similar to a path inside a filesystem.
	FlightDescriptor_PATH FlightDescriptor_DescriptorType = 1
	//
	// An opaque command to generate a dataset.
	FlightDescriptor_CMD FlightDescriptor_DescriptorType = 2
)

func (FlightDescriptor_DescriptorType) Descriptor

func (FlightDescriptor_DescriptorType) Enum

func (FlightDescriptor_DescriptorType) EnumDescriptor deprecated

func (FlightDescriptor_DescriptorType) EnumDescriptor() ([]byte, []int)

Deprecated: Use FlightDescriptor_DescriptorType.Descriptor instead.

func (FlightDescriptor_DescriptorType) Number

func (FlightDescriptor_DescriptorType) String

func (FlightDescriptor_DescriptorType) Type

type FlightEndpoint

type FlightEndpoint struct {

	//
	// Token used to retrieve this stream.
	Ticket *Ticket `protobuf:"bytes,1,opt,name=ticket,proto3" json:"ticket,omitempty"`
	//
	// A list of URIs where this ticket can be redeemed. If the list is
	// empty, the expectation is that the ticket can only be redeemed on the
	// current service where the ticket was generated.
	Location []*Location `protobuf:"bytes,2,rep,name=location,proto3" json:"location,omitempty"`
	// contains filtered or unexported fields
}

A particular stream or split associated with a flight.

func (*FlightEndpoint) Descriptor deprecated

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

Deprecated: Use FlightEndpoint.ProtoReflect.Descriptor instead.

func (*FlightEndpoint) GetLocation

func (x *FlightEndpoint) GetLocation() []*Location

func (*FlightEndpoint) GetTicket

func (x *FlightEndpoint) GetTicket() *Ticket

func (*FlightEndpoint) ProtoMessage

func (*FlightEndpoint) ProtoMessage()

func (*FlightEndpoint) ProtoReflect

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

func (*FlightEndpoint) Reset

func (x *FlightEndpoint) Reset()

func (*FlightEndpoint) String

func (x *FlightEndpoint) String() string

type FlightInfo

type FlightInfo struct {

	// schema of the dataset as described in Schema.fbs::Schema.
	Schema []byte `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"`
	//
	// The descriptor associated with this info.
	FlightDescriptor *FlightDescriptor `protobuf:"bytes,2,opt,name=flight_descriptor,json=flightDescriptor,proto3" json:"flight_descriptor,omitempty"`
	//
	// A list of endpoints associated with the flight. To consume the whole
	// flight, all endpoints must be consumed.
	Endpoint []*FlightEndpoint `protobuf:"bytes,3,rep,name=endpoint,proto3" json:"endpoint,omitempty"`
	// Set these to -1 if unknown.
	TotalRecords int64 `protobuf:"varint,4,opt,name=total_records,json=totalRecords,proto3" json:"total_records,omitempty"`
	TotalBytes   int64 `protobuf:"varint,5,opt,name=total_bytes,json=totalBytes,proto3" json:"total_bytes,omitempty"`
	// contains filtered or unexported fields
}

The access coordinates for retrieval of a dataset. With a FlightInfo, a consumer is able to determine how to retrieve a dataset.

func (*FlightInfo) Descriptor deprecated

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

Deprecated: Use FlightInfo.ProtoReflect.Descriptor instead.

func (*FlightInfo) GetEndpoint

func (x *FlightInfo) GetEndpoint() []*FlightEndpoint

func (*FlightInfo) GetFlightDescriptor

func (x *FlightInfo) GetFlightDescriptor() *FlightDescriptor

func (*FlightInfo) GetSchema

func (x *FlightInfo) GetSchema() []byte

func (*FlightInfo) GetTotalBytes

func (x *FlightInfo) GetTotalBytes() int64

func (*FlightInfo) GetTotalRecords

func (x *FlightInfo) GetTotalRecords() int64

func (*FlightInfo) ProtoMessage

func (*FlightInfo) ProtoMessage()

func (*FlightInfo) ProtoReflect

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

func (*FlightInfo) Reset

func (x *FlightInfo) Reset()

func (*FlightInfo) String

func (x *FlightInfo) String() string

type FlightServiceClient

type FlightServiceClient interface {
	//
	// Handshake between client and server. Depending on the server, the
	// handshake may be required to determine the token that should be used for
	// future operations. Both request and response are streams to allow multiple
	// round-trips depending on auth mechanism.
	Handshake(ctx context.Context, opts ...grpc.CallOption) (FlightService_HandshakeClient, error)
	//
	// Get a list of available streams given a particular criteria. Most flight
	// services will expose one or more streams that are readily available for
	// retrieval. This api allows listing the streams available for
	// consumption. A user can also provide a criteria. The criteria can limit
	// the subset of streams that can be listed via this interface. Each flight
	// service allows its own definition of how to consume criteria.
	ListFlights(ctx context.Context, in *Criteria, opts ...grpc.CallOption) (FlightService_ListFlightsClient, error)
	//
	// For a given FlightDescriptor, get information about how the flight can be
	// consumed. This is a useful interface if the consumer of the interface
	// already can identify the specific flight to consume. This interface can
	// also allow a consumer to generate a flight stream through a specified
	// descriptor. For example, a flight descriptor might be something that
	// includes a SQL statement or a Pickled Python operation that will be
	// executed. In those cases, the descriptor will not be previously available
	// within the list of available streams provided by ListFlights but will be
	// available for consumption for the duration defined by the specific flight
	// service.
	GetFlightInfo(ctx context.Context, in *FlightDescriptor, opts ...grpc.CallOption) (*FlightInfo, error)
	//
	// For a given FlightDescriptor, get the Schema as described in Schema.fbs::Schema
	// This is used when a consumer needs the Schema of flight stream. Similar to
	// GetFlightInfo this interface may generate a new flight that was not previously
	// available in ListFlights.
	GetSchema(ctx context.Context, in *FlightDescriptor, opts ...grpc.CallOption) (*SchemaResult, error)
	//
	// Retrieve a single stream associated with a particular descriptor
	// associated with the referenced ticket. A Flight can be composed of one or
	// more streams where each stream can be retrieved using a separate opaque
	// ticket that the flight service uses for managing a collection of streams.
	DoGet(ctx context.Context, in *Ticket, opts ...grpc.CallOption) (FlightService_DoGetClient, error)
	//
	// Push a stream to the flight service associated with a particular
	// flight stream. This allows a client of a flight service to upload a stream
	// of data. Depending on the particular flight service, a client consumer
	// could be allowed to upload a single stream per descriptor or an unlimited
	// number. In the latter, the service might implement a 'seal' action that
	// can be applied to a descriptor once all streams are uploaded.
	DoPut(ctx context.Context, opts ...grpc.CallOption) (FlightService_DoPutClient, error)
	//
	// Open a bidirectional data channel for a given descriptor. This
	// allows clients to send and receive arbitrary Arrow data and
	// application-specific metadata in a single logical stream. In
	// contrast to DoGet/DoPut, this is more suited for clients
	// offloading computation (rather than storage) to a Flight service.
	DoExchange(ctx context.Context, opts ...grpc.CallOption) (FlightService_DoExchangeClient, error)
	//
	// Flight services can support an arbitrary number of simple actions in
	// addition to the possible ListFlights, GetFlightInfo, DoGet, DoPut
	// operations that are potentially available. DoAction allows a flight client
	// to do a specific action against a flight service. An action includes
	// opaque request and response objects that are specific to the type action
	// being undertaken.
	DoAction(ctx context.Context, in *Action, opts ...grpc.CallOption) (FlightService_DoActionClient, error)
	//
	// A flight service exposes all of the available action types that it has
	// along with descriptions. This allows different flight consumers to
	// understand the capabilities of the flight service.
	ListActions(ctx context.Context, in *Empty, opts ...grpc.CallOption) (FlightService_ListActionsClient, error)
}

FlightServiceClient is the client API for FlightService service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

type FlightServiceService

type FlightServiceService struct {
	//
	// Handshake between client and server. Depending on the server, the
	// handshake may be required to determine the token that should be used for
	// future operations. Both request and response are streams to allow multiple
	// round-trips depending on auth mechanism.
	Handshake func(FlightService_HandshakeServer) error
	//
	// Get a list of available streams given a particular criteria. Most flight
	// services will expose one or more streams that are readily available for
	// retrieval. This api allows listing the streams available for
	// consumption. A user can also provide a criteria. The criteria can limit
	// the subset of streams that can be listed via this interface. Each flight
	// service allows its own definition of how to consume criteria.
	ListFlights func(*Criteria, FlightService_ListFlightsServer) error
	//
	// For a given FlightDescriptor, get information about how the flight can be
	// consumed. This is a useful interface if the consumer of the interface
	// already can identify the specific flight to consume. This interface can
	// also allow a consumer to generate a flight stream through a specified
	// descriptor. For example, a flight descriptor might be something that
	// includes a SQL statement or a Pickled Python operation that will be
	// executed. In those cases, the descriptor will not be previously available
	// within the list of available streams provided by ListFlights but will be
	// available for consumption for the duration defined by the specific flight
	// service.
	GetFlightInfo func(context.Context, *FlightDescriptor) (*FlightInfo, error)
	//
	// For a given FlightDescriptor, get the Schema as described in Schema.fbs::Schema
	// This is used when a consumer needs the Schema of flight stream. Similar to
	// GetFlightInfo this interface may generate a new flight that was not previously
	// available in ListFlights.
	GetSchema func(context.Context, *FlightDescriptor) (*SchemaResult, error)
	//
	// Retrieve a single stream associated with a particular descriptor
	// associated with the referenced ticket. A Flight can be composed of one or
	// more streams where each stream can be retrieved using a separate opaque
	// ticket that the flight service uses for managing a collection of streams.
	DoGet func(*Ticket, FlightService_DoGetServer) error
	//
	// Push a stream to the flight service associated with a particular
	// flight stream. This allows a client of a flight service to upload a stream
	// of data. Depending on the particular flight service, a client consumer
	// could be allowed to upload a single stream per descriptor or an unlimited
	// number. In the latter, the service might implement a 'seal' action that
	// can be applied to a descriptor once all streams are uploaded.
	DoPut func(FlightService_DoPutServer) error
	//
	// Open a bidirectional data channel for a given descriptor. This
	// allows clients to send and receive arbitrary Arrow data and
	// application-specific metadata in a single logical stream. In
	// contrast to DoGet/DoPut, this is more suited for clients
	// offloading computation (rather than storage) to a Flight service.
	DoExchange func(FlightService_DoExchangeServer) error
	//
	// Flight services can support an arbitrary number of simple actions in
	// addition to the possible ListFlights, GetFlightInfo, DoGet, DoPut
	// operations that are potentially available. DoAction allows a flight client
	// to do a specific action against a flight service. An action includes
	// opaque request and response objects that are specific to the type action
	// being undertaken.
	DoAction func(*Action, FlightService_DoActionServer) error
	//
	// A flight service exposes all of the available action types that it has
	// along with descriptions. This allows different flight consumers to
	// understand the capabilities of the flight service.
	ListActions func(*Empty, FlightService_ListActionsServer) error
}

FlightServiceService is the service API for FlightService service. Fields should be assigned to their respective handler implementations only before RegisterFlightServiceService is called. Any unassigned fields will result in the handler for that method returning an Unimplemented error.

func NewFlightServiceService

func NewFlightServiceService(s interface{}) *FlightServiceService

NewFlightServiceService creates a new FlightServiceService containing the implemented methods of the FlightService service in s. Any unimplemented methods will result in the gRPC server returning an UNIMPLEMENTED status to the client. This includes situations where the method handler is misspelled or has the wrong signature. For this reason, this function should be used with great care and is not recommended to be used by most users.

type FlightService_DoActionClient

type FlightService_DoActionClient interface {
	Recv() (*Result, error)
	grpc.ClientStream
}

type FlightService_DoActionServer

type FlightService_DoActionServer interface {
	Send(*Result) error
	grpc.ServerStream
}

type FlightService_DoExchangeClient

type FlightService_DoExchangeClient interface {
	Send(*FlightData) error
	Recv() (*FlightData, error)
	grpc.ClientStream
}

type FlightService_DoExchangeServer

type FlightService_DoExchangeServer interface {
	Send(*FlightData) error
	Recv() (*FlightData, error)
	grpc.ServerStream
}

type FlightService_DoGetClient

type FlightService_DoGetClient interface {
	Recv() (*FlightData, error)
	grpc.ClientStream
}

type FlightService_DoGetServer

type FlightService_DoGetServer interface {
	Send(*FlightData) error
	grpc.ServerStream
}

type FlightService_DoPutClient

type FlightService_DoPutClient interface {
	Send(*FlightData) error
	Recv() (*PutResult, error)
	grpc.ClientStream
}

type FlightService_DoPutServer

type FlightService_DoPutServer interface {
	Send(*PutResult) error
	Recv() (*FlightData, error)
	grpc.ServerStream
}

type FlightService_HandshakeClient

type FlightService_HandshakeClient interface {
	Send(*HandshakeRequest) error
	Recv() (*HandshakeResponse, error)
	grpc.ClientStream
}

type FlightService_HandshakeServer

type FlightService_HandshakeServer interface {
	Send(*HandshakeResponse) error
	Recv() (*HandshakeRequest, error)
	grpc.ServerStream
}

type FlightService_ListActionsClient

type FlightService_ListActionsClient interface {
	Recv() (*ActionType, error)
	grpc.ClientStream
}

type FlightService_ListActionsServer

type FlightService_ListActionsServer interface {
	Send(*ActionType) error
	grpc.ServerStream
}

type FlightService_ListFlightsClient

type FlightService_ListFlightsClient interface {
	Recv() (*FlightInfo, error)
	grpc.ClientStream
}

type FlightService_ListFlightsServer

type FlightService_ListFlightsServer interface {
	Send(*FlightInfo) error
	grpc.ServerStream
}

type HandshakeRequest

type HandshakeRequest struct {

	//
	// A defined protocol version
	ProtocolVersion uint64 `protobuf:"varint,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
	//
	// Arbitrary auth/handshake info.
	Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	// contains filtered or unexported fields
}

The request that a client provides to a server on handshake.

func (*HandshakeRequest) Descriptor deprecated

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

Deprecated: Use HandshakeRequest.ProtoReflect.Descriptor instead.

func (*HandshakeRequest) GetPayload

func (x *HandshakeRequest) GetPayload() []byte

func (*HandshakeRequest) GetProtocolVersion

func (x *HandshakeRequest) GetProtocolVersion() uint64

func (*HandshakeRequest) ProtoMessage

func (*HandshakeRequest) ProtoMessage()

func (*HandshakeRequest) ProtoReflect

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

func (*HandshakeRequest) Reset

func (x *HandshakeRequest) Reset()

func (*HandshakeRequest) String

func (x *HandshakeRequest) String() string

type HandshakeResponse

type HandshakeResponse struct {

	//
	// A defined protocol version
	ProtocolVersion uint64 `protobuf:"varint,1,opt,name=protocol_version,json=protocolVersion,proto3" json:"protocol_version,omitempty"`
	//
	// Arbitrary auth/handshake info.
	Payload []byte `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"`
	// contains filtered or unexported fields
}

func (*HandshakeResponse) Descriptor deprecated

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

Deprecated: Use HandshakeResponse.ProtoReflect.Descriptor instead.

func (*HandshakeResponse) GetPayload

func (x *HandshakeResponse) GetPayload() []byte

func (*HandshakeResponse) GetProtocolVersion

func (x *HandshakeResponse) GetProtocolVersion() uint64

func (*HandshakeResponse) ProtoMessage

func (*HandshakeResponse) ProtoMessage()

func (*HandshakeResponse) ProtoReflect

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

func (*HandshakeResponse) Reset

func (x *HandshakeResponse) Reset()

func (*HandshakeResponse) String

func (x *HandshakeResponse) String() string

type Location

type Location struct {
	Uri string `protobuf:"bytes,1,opt,name=uri,proto3" json:"uri,omitempty"`
	// contains filtered or unexported fields
}

A location where a Flight service will accept retrieval of a particular stream given a ticket.

func (*Location) Descriptor deprecated

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

Deprecated: Use Location.ProtoReflect.Descriptor instead.

func (*Location) GetUri

func (x *Location) GetUri() string

func (*Location) ProtoMessage

func (*Location) ProtoMessage()

func (*Location) ProtoReflect

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

func (*Location) Reset

func (x *Location) Reset()

func (*Location) String

func (x *Location) String() string

type PutResult

type PutResult struct {
	AppMetadata []byte `protobuf:"bytes,1,opt,name=app_metadata,json=appMetadata,proto3" json:"app_metadata,omitempty"`
	// contains filtered or unexported fields
}

* The response message associated with the submission of a DoPut.

func (*PutResult) Descriptor deprecated

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

Deprecated: Use PutResult.ProtoReflect.Descriptor instead.

func (*PutResult) GetAppMetadata

func (x *PutResult) GetAppMetadata() []byte

func (*PutResult) ProtoMessage

func (*PutResult) ProtoMessage()

func (*PutResult) ProtoReflect

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

func (*PutResult) Reset

func (x *PutResult) Reset()

func (*PutResult) String

func (x *PutResult) String() string

type Reader

type Reader struct {
	*ipc.Reader
	// contains filtered or unexported fields
}

Reader is an ipc.Reader which also keeps track of the metadata from the FlightData messages as they come in, calling LatestAppMetadata will return the metadata bytes from the most recently read message.

func NewRecordReader

func NewRecordReader(r DataStreamReader, opts ...ipc.Option) (*Reader, error)

NewRecordReader constructs an ipc reader using the flight data stream reader as the source of the ipc messages, opts passed will be passed to the underlying ipc.Reader such as ipc.WithSchema and ipc.WithAllocator

func (*Reader) LatestAppMetadata

func (r *Reader) LatestAppMetadata() []byte

LatestAppMetadata returns the bytes from the AppMetadata field of the most recently read FlightData message that was processed by calling the Next function. The metadata returned would correspond to the record retrieved by calling Record().

func (*Reader) LatestFlightDescriptor

func (r *Reader) LatestFlightDescriptor() *FlightDescriptor

LatestFlightDescriptor returns a pointer to the last FlightDescriptor object that was received in the most recently read FlightData message that was processed by calling the Next function. The descriptor returned would correspond to the record retrieved by calling Record().

func (*Reader) Release

func (r *Reader) Release()

Release reduces the reference count for the underlying message reader and ipc.Reader, when the reference counts become zero, the allocated memory is released for the stored record and metadata.

func (*Reader) Retain

func (r *Reader) Retain()

Retain increases the reference count for the underlying message reader and ipc.Reader which are utilized by this Reader.

type Result

type Result struct {
	Body []byte `protobuf:"bytes,1,opt,name=body,proto3" json:"body,omitempty"`
	// contains filtered or unexported fields
}

An opaque result returned after executing an action.

func (*Result) Descriptor deprecated

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

Deprecated: Use Result.ProtoReflect.Descriptor instead.

func (*Result) GetBody

func (x *Result) GetBody() []byte

func (*Result) ProtoMessage

func (*Result) ProtoMessage()

func (*Result) ProtoReflect

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

func (*Result) Reset

func (x *Result) Reset()

func (*Result) String

func (x *Result) String() string

type SchemaResult

type SchemaResult struct {

	// schema of the dataset as described in Schema.fbs::Schema.
	Schema []byte `protobuf:"bytes,1,opt,name=schema,proto3" json:"schema,omitempty"`
	// contains filtered or unexported fields
}

Wrap the result of a getSchema call

func (*SchemaResult) Descriptor deprecated

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

Deprecated: Use SchemaResult.ProtoReflect.Descriptor instead.

func (*SchemaResult) GetSchema

func (x *SchemaResult) GetSchema() []byte

func (*SchemaResult) ProtoMessage

func (*SchemaResult) ProtoMessage()

func (*SchemaResult) ProtoReflect

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

func (*SchemaResult) Reset

func (x *SchemaResult) Reset()

func (*SchemaResult) String

func (x *SchemaResult) String() string

type Server

type Server interface {
	// Init takes in the address to bind to and creates the listener
	Init(addr string) error
	// Addr will return the address that was bound to for the service to listen on
	Addr() net.Addr
	// SetShutdownOnSignals sets notifications on the given signals to call GracefulStop
	// on the grpc service if any of those signals are received
	SetShutdownOnSignals(sig ...os.Signal)
	// Serve blocks until accepting a connection fails with a fatal error. It will return
	// a non-nil error unless it stopped due to calling Shutdown or receiving one of the
	// signals set in SetShutdownOnSignals
	Serve() error
	// Shutdown will call GracefulStop on the grpc server so that it stops accepting connections
	// and will wait until current methods complete
	Shutdown()
	// RegisterFlightService sets up the handler for the Flight Endpoints as per
	// normal Grpc setups
	RegisterFlightService(*FlightServiceService)
}

Server is an interface for hiding some of the grpc specifics to make it slightly easier to manage a flight service, slightly modeled after the C++ implementation

func NewFlightServer deprecated

func NewFlightServer(auth ServerAuthHandler, opt ...grpc.ServerOption) Server

NewFlightServer takes in an auth handler for managing the handshake authentication and any grpc Server options desired, such as TLS certs and so on which will just be passed through to the underlying grpc server.

Alternatively, a grpc server can be created normally without this helper as the grpc server generated code is still being exported. This only exists to allow the utility of the helpers

Deprecated: prefer to use NewServerWithMiddleware

func NewServerWithMiddleware

func NewServerWithMiddleware(auth ServerAuthHandler, middleware []ServerMiddleware, opts ...grpc.ServerOption) Server

NewServerWithMiddleware takes a slice of middleware which will be used by grpc and chained, the first middleware will be the outer most with the last middleware being the inner most wrapper around the actual call. It also takes any grpc Server options desired, such as TLS certs and so on which will just be passed through to the underlying grpc server.

Alternatively, a grpc server can be created normally without this helper as the grpc server generated code is still being exported. This only exists to allow the utility of the helpers

type ServerAuthHandler

type ServerAuthHandler interface {
	Authenticate(AuthConn) error
	IsValid(token string) (interface{}, error)
}

ServerAuthHandler defines an interface for the server to perform the handshake. The token is expected to be sent as part of the context metadata in subsequent requests with a key of "auth-token-bin" which will then call IsValid to validate

type ServerMiddleware

type ServerMiddleware struct {
	Stream grpc.StreamServerInterceptor
	Unary  grpc.UnaryServerInterceptor
}

func CreateServerBasicAuthMiddleware

func CreateServerBasicAuthMiddleware(validator BasicAuthValidator) ServerMiddleware

CreateServerBasicAuthMiddleware returns a ServerMiddleware that can be passed to NewServerWithMiddleware in order to automatically add interceptors which will properly enforce auth validation as per the passed in BasicAuthValidator.

validator cannot be nil.

func CreateServerMiddleware

func CreateServerMiddleware(middleware CustomServerMiddleware) ServerMiddleware

type Ticket

type Ticket struct {
	Ticket []byte `protobuf:"bytes,1,opt,name=ticket,proto3" json:"ticket,omitempty"`
	// contains filtered or unexported fields
}

An opaque identifier that the service can use to retrieve a particular portion of a stream.

func (*Ticket) Descriptor deprecated

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

Deprecated: Use Ticket.ProtoReflect.Descriptor instead.

func (*Ticket) GetTicket

func (x *Ticket) GetTicket() []byte

func (*Ticket) ProtoMessage

func (*Ticket) ProtoMessage()

func (*Ticket) ProtoReflect

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

func (*Ticket) Reset

func (x *Ticket) Reset()

func (*Ticket) String

func (x *Ticket) String() string

type UnstableFlightServiceService

type UnstableFlightServiceService interface {
	//
	// Handshake between client and server. Depending on the server, the
	// handshake may be required to determine the token that should be used for
	// future operations. Both request and response are streams to allow multiple
	// round-trips depending on auth mechanism.
	Handshake(FlightService_HandshakeServer) error
	//
	// Get a list of available streams given a particular criteria. Most flight
	// services will expose one or more streams that are readily available for
	// retrieval. This api allows listing the streams available for
	// consumption. A user can also provide a criteria. The criteria can limit
	// the subset of streams that can be listed via this interface. Each flight
	// service allows its own definition of how to consume criteria.
	ListFlights(*Criteria, FlightService_ListFlightsServer) error
	//
	// For a given FlightDescriptor, get information about how the flight can be
	// consumed. This is a useful interface if the consumer of the interface
	// already can identify the specific flight to consume. This interface can
	// also allow a consumer to generate a flight stream through a specified
	// descriptor. For example, a flight descriptor might be something that
	// includes a SQL statement or a Pickled Python operation that will be
	// executed. In those cases, the descriptor will not be previously available
	// within the list of available streams provided by ListFlights but will be
	// available for consumption for the duration defined by the specific flight
	// service.
	GetFlightInfo(context.Context, *FlightDescriptor) (*FlightInfo, error)
	//
	// For a given FlightDescriptor, get the Schema as described in Schema.fbs::Schema
	// This is used when a consumer needs the Schema of flight stream. Similar to
	// GetFlightInfo this interface may generate a new flight that was not previously
	// available in ListFlights.
	GetSchema(context.Context, *FlightDescriptor) (*SchemaResult, error)
	//
	// Retrieve a single stream associated with a particular descriptor
	// associated with the referenced ticket. A Flight can be composed of one or
	// more streams where each stream can be retrieved using a separate opaque
	// ticket that the flight service uses for managing a collection of streams.
	DoGet(*Ticket, FlightService_DoGetServer) error
	//
	// Push a stream to the flight service associated with a particular
	// flight stream. This allows a client of a flight service to upload a stream
	// of data. Depending on the particular flight service, a client consumer
	// could be allowed to upload a single stream per descriptor or an unlimited
	// number. In the latter, the service might implement a 'seal' action that
	// can be applied to a descriptor once all streams are uploaded.
	DoPut(FlightService_DoPutServer) error
	//
	// Open a bidirectional data channel for a given descriptor. This
	// allows clients to send and receive arbitrary Arrow data and
	// application-specific metadata in a single logical stream. In
	// contrast to DoGet/DoPut, this is more suited for clients
	// offloading computation (rather than storage) to a Flight service.
	DoExchange(FlightService_DoExchangeServer) error
	//
	// Flight services can support an arbitrary number of simple actions in
	// addition to the possible ListFlights, GetFlightInfo, DoGet, DoPut
	// operations that are potentially available. DoAction allows a flight client
	// to do a specific action against a flight service. An action includes
	// opaque request and response objects that are specific to the type action
	// being undertaken.
	DoAction(*Action, FlightService_DoActionServer) error
	//
	// A flight service exposes all of the available action types that it has
	// along with descriptions. This allows different flight consumers to
	// understand the capabilities of the flight service.
	ListActions(*Empty, FlightService_ListActionsServer) error
}

UnstableFlightServiceService is the service API for FlightService service. New methods may be added to this interface if they are added to the service definition, which is not a backward-compatible change. For this reason, use of this type is not recommended.

type Writer

type Writer struct {
	*ipc.Writer
	// contains filtered or unexported fields
}

Writer is an ipc.Writer which also adds a WriteWithAppMetadata function in order to allow adding AppMetadata to the FlightData messages which are written.

func NewRecordWriter

func NewRecordWriter(w DataStreamWriter, opts ...ipc.Option) *Writer

NewRecordWriter can be used to construct a writer for arrow flight via the grpc stream handler to write flight data objects and write record batches to the stream. Options passed here will be passed to ipc.NewWriter

func (*Writer) SetFlightDescriptor

func (w *Writer) SetFlightDescriptor(descr *FlightDescriptor)

SetFlightDescriptor sets the flight descriptor into the next payload that will be written by the flight writer. It will only be put into the very next payload and afterwards the writer will no longer keep it's pointer to the descriptor.

func (*Writer) Write

func (w *Writer) Write(rec array.Record) error

Write writes a recordbatch payload and returns any error, implementing the arrio.Writer interface

func (*Writer) WriteWithAppMetadata

func (w *Writer) WriteWithAppMetadata(rec array.Record, appMeta []byte) error

WriteWithAppMetadata will write this record with the supplied application metadata attached in the flightData message.

Jump to

Keyboard shortcuts

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