grpcserver

package
v1.18.14 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: BSD-3-Clause Imports: 27 Imported by: 0

Documentation

Overview

Package grpcserver provides ConnectRPC service handlers for the PeeringDB gRPC API. Each handler implements the generated service interface and queries the ent database layer.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListEntities added in v1.9.0

func ListEntities[E any, P any](ctx context.Context, params ListParams[E, P]) ([]*P, string, error)

ListEntities executes a paginated list query using type-specific callbacks. Returns converted proto items, next page token, and any error.

func StreamEntities added in v1.9.0

func StreamEntities[E any, P any](ctx context.Context, params StreamParams[E, P], stream *connect.ServerStream[P]) error

StreamEntities streams all matching entities using batched keyset pagination. Handles timeout, count header, SinceID/UpdatedSince, and batch iteration.

Header contract (PERF-06): on full streams (SinceID == nil AND UpdatedSince == nil) a SELECT COUNT(*) preflight runs and the grpc-total-count response header is set to the total matching row count. On delta streams (SinceID or UpdatedSince set) the COUNT preflight is skipped entirely and the grpc-total-count response header is absent — not "present with 0", not "present with -1". Delta clients pull incremental ranges and have no use for a full-table total, so we do not pay for the count.

Types

type CampusService

type CampusService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

CampusService implements the peeringdb.v1.CampusService ConnectRPC handler interface. It queries the ent database layer and converts results to protobuf messages.

func (*CampusService) GetCampus

GetCampus returns a single campus by ID. Returns NOT_FOUND if the campus does not exist.

func (*CampusService) ListCampuses

ListCampuses returns a paginated list of campuses under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*CampusService) StreamCampuses added in v1.7.0

func (s *CampusService) StreamCampuses(ctx context.Context, req *pb.StreamCampusesRequest, stream *connect.ServerStream[pb.Campus]) error

StreamCampuses streams all matching campuses via compound (updated, id) keyset pagination under the (-updated, -created, -id) default order.

type CarrierFacilityService

type CarrierFacilityService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

CarrierFacilityService implements the peeringdb.v1.CarrierFacilityService ConnectRPC handler interface.

func (*CarrierFacilityService) GetCarrierFacility

GetCarrierFacility returns a single carrier facility by ID.

func (*CarrierFacilityService) ListCarrierFacilities

ListCarrierFacilities returns a paginated list of carrier facilities under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*CarrierFacilityService) StreamCarrierFacilities added in v1.7.0

StreamCarrierFacilities streams all matching carrier facilities via compound (updated, id) keyset pagination under the (-updated, -created, -id) order.

type CarrierService

type CarrierService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

CarrierService implements the peeringdb.v1.CarrierService ConnectRPC handler interface. It queries the ent database layer and converts results to protobuf messages.

func (*CarrierService) GetCarrier

GetCarrier returns a single carrier by ID. Returns NOT_FOUND if the carrier does not exist.

func (*CarrierService) ListCarriers

ListCarriers returns a paginated list of carriers under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*CarrierService) StreamCarriers added in v1.7.0

func (s *CarrierService) StreamCarriers(ctx context.Context, req *pb.StreamCarriersRequest, stream *connect.ServerStream[pb.Carrier]) error

StreamCarriers streams all matching carriers via compound (updated, id) keyset pagination under the (-updated, -created, -id) default order.

type FacilityService

type FacilityService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

FacilityService implements the peeringdb.v1.FacilityService ConnectRPC handler interface. It queries the ent database layer and converts results to protobuf messages.

func (*FacilityService) GetFacility

GetFacility returns a single facility by ID. Returns NOT_FOUND if the facility does not exist.

func (*FacilityService) ListFacilities

ListFacilities returns a paginated list of facilities under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*FacilityService) StreamFacilities added in v1.7.0

func (s *FacilityService) StreamFacilities(ctx context.Context, req *pb.StreamFacilitiesRequest, stream *connect.ServerStream[pb.Facility]) error

StreamFacilities streams all matching facilities via compound (updated, id) keyset pagination under the (-updated, -created, -id) default order.

type InternetExchangeService

type InternetExchangeService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

InternetExchangeService implements the peeringdb.v1.InternetExchangeService ConnectRPC handler interface. It queries the ent database layer and converts results to protobuf messages.

func (*InternetExchangeService) GetInternetExchange

GetInternetExchange returns a single internet exchange by ID. Returns NOT_FOUND if the internet exchange does not exist.

func (*InternetExchangeService) ListInternetExchanges

ListInternetExchanges returns a paginated list of internet exchanges under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*InternetExchangeService) StreamInternetExchanges added in v1.7.0

StreamInternetExchanges streams all matching internet exchanges via compound (updated, id) keyset pagination under the (-updated, -created, -id) order.

type IxFacilityService

type IxFacilityService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

IxFacilityService implements the peeringdb.v1.IxFacilityService ConnectRPC handler interface.

func (*IxFacilityService) GetIxFacility

GetIxFacility returns a single IX facility by ID.

func (*IxFacilityService) ListIxFacilities

ListIxFacilities returns a paginated list of IX facilities under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*IxFacilityService) StreamIxFacilities added in v1.7.0

StreamIxFacilities streams all matching IX facilities via compound (updated, id) keyset pagination under the (-updated, -created, -id) order.

type IxLanService

type IxLanService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

IxLanService implements the peeringdb.v1.IxLanService ConnectRPC handler interface.

func (*IxLanService) GetIxLan

GetIxLan returns a single IX LAN by ID.

func (*IxLanService) ListIxLans

ListIxLans returns a paginated list of IX LANs under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*IxLanService) StreamIxLans added in v1.7.0

func (s *IxLanService) StreamIxLans(ctx context.Context, req *pb.StreamIxLansRequest, stream *connect.ServerStream[pb.IxLan]) error

StreamIxLans streams all matching IX LANs via compound (updated, id) keyset pagination under the (-updated, -created, -id) default order.

type IxPrefixService

type IxPrefixService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

IxPrefixService implements the peeringdb.v1.IxPrefixService ConnectRPC handler interface.

func (*IxPrefixService) GetIxPrefix

GetIxPrefix returns a single IX prefix by ID.

func (*IxPrefixService) ListIxPrefixes

ListIxPrefixes returns a paginated list of IX prefixes under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*IxPrefixService) StreamIxPrefixes added in v1.7.0

func (s *IxPrefixService) StreamIxPrefixes(ctx context.Context, req *pb.StreamIxPrefixesRequest, stream *connect.ServerStream[pb.IxPrefix]) error

StreamIxPrefixes streams all matching IX prefixes via compound (updated, id) keyset pagination under the (-updated, -created, -id) default order.

type ListParams added in v1.9.0

type ListParams[E any, P any] struct {
	EntityName   string
	PageSize     int32
	PageToken    string
	ApplyFilters func() ([]func(*sql.Selector), error)
	Query        func(ctx context.Context, predicates []func(*sql.Selector), limit, offset int) ([]*E, error)
	Convert      func(*E) *P
}

ListParams holds type-specific callbacks for a paginated list query. E is the ent entity type, P is the proto message type.

type NetworkFacilityService

type NetworkFacilityService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

NetworkFacilityService implements the peeringdb.v1.NetworkFacilityService ConnectRPC handler interface.

func (*NetworkFacilityService) GetNetworkFacility

GetNetworkFacility returns a single network facility by ID.

func (*NetworkFacilityService) ListNetworkFacilities

ListNetworkFacilities returns a paginated list of network facilities under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*NetworkFacilityService) StreamNetworkFacilities added in v1.7.0

StreamNetworkFacilities streams all matching network facilities via compound (updated, id) keyset pagination under the (-updated, -created, -id) order.

type NetworkIxLanService

type NetworkIxLanService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

NetworkIxLanService implements the peeringdb.v1.NetworkIxLanService ConnectRPC handler interface.

func (*NetworkIxLanService) GetNetworkIxLan

GetNetworkIxLan returns a single network IX LAN by ID.

func (*NetworkIxLanService) ListNetworkIxLans

ListNetworkIxLans returns a paginated list of network IX LANs under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*NetworkIxLanService) StreamNetworkIxLans added in v1.7.0

StreamNetworkIxLans streams all matching network IX LANs via compound (updated, id) keyset pagination under the (-updated, -created, -id) order.

type NetworkService

type NetworkService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

NetworkService implements the peeringdb.v1.NetworkService ConnectRPC handler interface. It queries the ent database layer and converts results to protobuf messages.

func (*NetworkService) GetNetwork

GetNetwork returns a single network by ID. Returns NOT_FOUND if the network does not exist.

func (*NetworkService) ListNetworks

ListNetworks returns a paginated list of networks ordered by the compound default order (-updated, -created, -id) per Phase 67 ORDER-02. Supports all pdbcompat-parity filter fields with AND logic.

func (*NetworkService) StreamNetworks added in v1.7.0

func (s *NetworkService) StreamNetworks(ctx context.Context, req *pb.StreamNetworksRequest, stream *connect.ServerStream[pb.Network]) error

StreamNetworks streams all matching networks one message at a time using batched compound (updated, id) keyset pagination under the (-updated, -created, -id) default order. Supports all pdbcompat-parity filter fields.

type OrganizationService

type OrganizationService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

OrganizationService implements the peeringdb.v1.OrganizationService ConnectRPC handler interface. It queries the ent database layer and converts results to protobuf messages.

func (*OrganizationService) GetOrganization

GetOrganization returns a single organization by ID. Returns NOT_FOUND if the organization does not exist.

func (*OrganizationService) ListOrganizations

ListOrganizations returns a paginated list of organizations under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02. Supports all pdbcompat-parity filter fields with AND logic.

func (*OrganizationService) StreamOrganizations added in v1.7.0

StreamOrganizations streams all matching organizations via compound (updated, id) keyset pagination under the (-updated, -created, -id) order.

type PocService

type PocService struct {
	Client        *ent.Client
	StreamTimeout time.Duration
}

PocService implements the peeringdb.v1.PocService ConnectRPC handler interface.

func (*PocService) GetPoc

func (s *PocService) GetPoc(ctx context.Context, req *pb.GetPocRequest) (*pb.GetPocResponse, error)

GetPoc returns a single point of contact by ID.

func (*PocService) ListPocs

func (s *PocService) ListPocs(ctx context.Context, req *pb.ListPocsRequest) (*pb.ListPocsResponse, error)

ListPocs returns a paginated list of points of contact under the compound default order (-updated, -created, -id) per Phase 67 ORDER-02.

func (*PocService) StreamPocs added in v1.7.0

func (s *PocService) StreamPocs(ctx context.Context, req *pb.StreamPocsRequest, stream *connect.ServerStream[pb.Poc]) error

StreamPocs streams all matching points of contact via compound (updated, id) keyset pagination under the (-updated, -created, -id) default order.

type StreamParams added in v1.9.0

type StreamParams[E any, P any] struct {
	EntityName   string
	Timeout      time.Duration
	SinceID      *int64
	UpdatedSince *timestamppb.Timestamp
	ApplyFilters func() ([]func(*sql.Selector), error)
	Count        func(ctx context.Context, predicates []func(*sql.Selector)) (int, error)
	// QueryBatch fetches the next batch under compound keyset pagination. When
	// cursor.empty() the query runs without a cursor predicate; otherwise the
	// handler emits the compound keyset predicate
	//   WHERE (updated < cursor.Updated) OR (updated = cursor.Updated AND id < cursor.ID)
	// under the `(-updated, -created, -id)` default order (Phase 67, CONTEXT.md
	// D-01 / D-05).
	QueryBatch func(ctx context.Context, predicates []func(*sql.Selector), cursor streamCursor, limit int) ([]*E, error)
	Convert    func(*E) *P
	GetID      func(*E) int
	// GetUpdated extracts the `updated` timestamp from an entity for the
	// compound cursor's primary key. Required by StreamEntities to emit the
	// next-batch cursor after each batch drains.
	GetUpdated func(*E) time.Time
}

StreamParams holds type-specific callbacks for a streaming query. E is the ent entity type, P is the proto message type.

Jump to

Keyboard shortcuts

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