pyarrow.flight.FlightServerBase#
- class pyarrow.flight.FlightServerBase(location=None, auth_handler=None, tls_certificates=None, verify_client=None, root_certificates=None, middleware=None)#
Bases:
_Weakrefable
A Flight service definition.
To start the server, create an instance of this class with an appropriate location. The server will be running as soon as the instance is created; it is not required to call
serve()
.Override methods to define your Flight service.
- Parameters:
- location
str
,tuple
orLocation
optional, defaultNone
Location to serve on. Either a gRPC URI like grpc://localhost:port, a tuple of (host, port) pair, or a Location instance. If None is passed then the server will be started on localhost with a system provided random port.
- auth_handler
ServerAuthHandler
optional, defaultNone
An authentication mechanism to use. May be None.
- tls_certificates
list
optional, defaultNone
A list of (certificate, key) pairs.
- verify_clientbool optional, default
False
If True, then enable mutual TLS: require the client to present a client certificate, and validate the certificate.
- root_certificates
bytes
optional, defaultNone
If enabling mutual TLS, this specifies the PEM-encoded root certificate used to validate client certificates.
- middleware
dict
optional, defaultNone
A dictionary of
ServerMiddlewareFactory
instances. The string keys can be used to retrieve the middleware instance within RPC handlers (seeServerCallContext.get_middleware()
).
- location
- __init__(*args, **kwargs)#
Methods
__init__
(*args, **kwargs)do_action
(self, context, action)Execute a custom action.
do_exchange
(self, context, descriptor, ...)Write data to a flight.
do_get
(self, context, ticket)Write data to a flight.
do_put
(self, context, descriptor, ...)Write data to a flight.
get_flight_info
(self, context, descriptor)Get information about a flight.
get_schema
(self, context, descriptor)Get the schema of a flight.
list_actions
(self, context)List custom actions available on this server.
list_flights
(self, context, criteria)List flights available on this service.
run
(self)Block until the server shuts down.
serve
(self)Block until the server shuts down.
shutdown
(self)Shut down the server, blocking until current requests finish.
wait
(self)Block until server is terminated with shutdown.
Attributes
Get the port that this server is listening on.
- do_action(self, context, action)#
Execute a custom action.
This method should return an iterator, or it should be a generator. Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext
Common contextual information.
- action
Action
The action to execute.
- context
- Returns:
- iterator of
bytes
- iterator of
- do_exchange(self, context, descriptor, reader, writer)#
Write data to a flight.
Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext
Common contextual information.
- descriptor
FlightDescriptor
The descriptor for the flight provided by the client.
- reader
MetadataRecordBatchReader
A reader for data uploaded by the client.
- writer
MetadataRecordBatchWriter
A writer to send responses to the client.
- context
- do_get(self, context, ticket)#
Write data to a flight.
Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext
Common contextual information.
- ticket
Ticket
The ticket for the flight.
- context
- Returns:
FlightDataStream
A stream of data to send back to the client.
- do_put(self, context, descriptor, MetadataRecordBatchReader reader: MetadataRecordBatchReader, FlightMetadataWriter writer: FlightMetadataWriter)#
Write data to a flight.
Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext
Common contextual information.
- descriptor
FlightDescriptor
The descriptor for the flight provided by the client.
- reader
MetadataRecordBatchReader
A reader for data uploaded by the client.
- writer
FlightMetadataWriter
A writer to send responses to the client.
- context
- get_flight_info(self, context, descriptor)#
Get information about a flight.
Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext
Common contextual information.
- descriptor
FlightDescriptor
The descriptor for the flight provided by the client.
- context
- Returns:
- get_schema(self, context, descriptor)#
Get the schema of a flight.
Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext
Common contextual information.
- descriptor
FlightDescriptor
The descriptor for the flight provided by the client.
- context
- Returns:
- list_actions(self, context)#
List custom actions available on this server.
Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext
Common contextual information.
- context
- Returns:
- iterator of
ActionType
ortuple
- iterator of
- list_flights(self, context, criteria)#
List flights available on this service.
Applications should override this method to implement their own behavior. The default method raises a NotImplementedError.
- Parameters:
- context
ServerCallContext
Common contextual information.
- criteria
bytes
Filter criteria provided by the client.
- context
- Returns:
- iterator of
FlightInfo
- iterator of
- port#
Get the port that this server is listening on.
Returns a non-positive value if the operation is invalid (e.g. init() was not called or server is listening on a domain socket).
- run(self)#
Block until the server shuts down.
Deprecated since version 0.15.0: Use the
FlightServer.serve
method instead
- serve(self)#
Block until the server shuts down.
This method only returns if shutdown() is called or a signal is received.
- shutdown(self)#
Shut down the server, blocking until current requests finish.
Do not call this directly from the implementation of a Flight method, as then the server will block forever waiting for that request to finish. Instead, call this method from a background thread.
This method should only be called once.
- wait(self)#
Block until server is terminated with shutdown.