// Code generated by protoc-gen-connect-go. DO NOT EDIT. // // Source: nostr/v1/nostr.proto package nostrv1connect import ( connect "connectrpc.com/connect" context "context" errors "errors" http "net/http" v1 "northwest.io/muxstr/api/nostr/v1" strings "strings" ) // This is a compile-time assertion to ensure that this generated file and the connect package are // compatible. If you get a compiler error that this constant is not defined, this code was // generated with a version of connect newer than the one compiled into your binary. You can fix the // problem by either regenerating this code with an older version of connect or updating the connect // version compiled into your binary. const _ = connect.IsAtLeastVersion1_13_0 const ( // NostrRelayName is the fully-qualified name of the NostrRelay service. NostrRelayName = "nostr.v1.NostrRelay" // RelayAdminName is the fully-qualified name of the RelayAdmin service. RelayAdminName = "nostr.v1.RelayAdmin" ) // These constants are the fully-qualified names of the RPCs defined in this package. They're // exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. // // Note that these are different from the fully-qualified method names used by // google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to // reflection-formatted method names, remove the leading slash and convert the remaining slash to a // period. const ( // NostrRelayPublishEventProcedure is the fully-qualified name of the NostrRelay's PublishEvent RPC. NostrRelayPublishEventProcedure = "/nostr.v1.NostrRelay/PublishEvent" // NostrRelaySubscribeProcedure is the fully-qualified name of the NostrRelay's Subscribe RPC. NostrRelaySubscribeProcedure = "/nostr.v1.NostrRelay/Subscribe" // NostrRelayUnsubscribeProcedure is the fully-qualified name of the NostrRelay's Unsubscribe RPC. NostrRelayUnsubscribeProcedure = "/nostr.v1.NostrRelay/Unsubscribe" // NostrRelayPublishBatchProcedure is the fully-qualified name of the NostrRelay's PublishBatch RPC. NostrRelayPublishBatchProcedure = "/nostr.v1.NostrRelay/PublishBatch" // NostrRelayQueryEventsProcedure is the fully-qualified name of the NostrRelay's QueryEvents RPC. NostrRelayQueryEventsProcedure = "/nostr.v1.NostrRelay/QueryEvents" // NostrRelayCountEventsProcedure is the fully-qualified name of the NostrRelay's CountEvents RPC. NostrRelayCountEventsProcedure = "/nostr.v1.NostrRelay/CountEvents" // RelayAdminGetStatsProcedure is the fully-qualified name of the RelayAdmin's GetStats RPC. RelayAdminGetStatsProcedure = "/nostr.v1.RelayAdmin/GetStats" // RelayAdminGetConnectionsProcedure is the fully-qualified name of the RelayAdmin's GetConnections // RPC. RelayAdminGetConnectionsProcedure = "/nostr.v1.RelayAdmin/GetConnections" // RelayAdminBanPublicKeyProcedure is the fully-qualified name of the RelayAdmin's BanPublicKey RPC. RelayAdminBanPublicKeyProcedure = "/nostr.v1.RelayAdmin/BanPublicKey" // RelayAdminGetStorageInfoProcedure is the fully-qualified name of the RelayAdmin's GetStorageInfo // RPC. RelayAdminGetStorageInfoProcedure = "/nostr.v1.RelayAdmin/GetStorageInfo" ) // NostrRelayClient is a client for the nostr.v1.NostrRelay service. type NostrRelayClient interface { // Publish a single event PublishEvent(context.Context, *connect.Request[v1.PublishEventRequest]) (*connect.Response[v1.PublishEventResponse], error) // Subscribe to events matching filters (streaming) Subscribe(context.Context, *connect.Request[v1.SubscribeRequest]) (*connect.ServerStreamForClient[v1.Event], error) // Unsubscribe from an active subscription Unsubscribe(context.Context, *connect.Request[v1.UnsubscribeRequest]) (*connect.Response[v1.Empty], error) // gRPC-specific: batch publish PublishBatch(context.Context, *connect.Request[v1.PublishBatchRequest]) (*connect.Response[v1.PublishBatchResponse], error) // gRPC-specific: paginated query (non-streaming) QueryEvents(context.Context, *connect.Request[v1.QueryRequest]) (*connect.Response[v1.QueryResponse], error) // Event counts (NIP-45) CountEvents(context.Context, *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) } // NewNostrRelayClient constructs a client for the nostr.v1.NostrRelay service. By default, it uses // the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends // uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or // connect.WithGRPCWeb() options. // // The URL supplied here should be the base URL for the Connect or gRPC server (for example, // http://api.acme.com or https://acme.com/grpc). func NewNostrRelayClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) NostrRelayClient { baseURL = strings.TrimRight(baseURL, "/") nostrRelayMethods := v1.File_nostr_v1_nostr_proto.Services().ByName("NostrRelay").Methods() return &nostrRelayClient{ publishEvent: connect.NewClient[v1.PublishEventRequest, v1.PublishEventResponse]( httpClient, baseURL+NostrRelayPublishEventProcedure, connect.WithSchema(nostrRelayMethods.ByName("PublishEvent")), connect.WithClientOptions(opts...), ), subscribe: connect.NewClient[v1.SubscribeRequest, v1.Event]( httpClient, baseURL+NostrRelaySubscribeProcedure, connect.WithSchema(nostrRelayMethods.ByName("Subscribe")), connect.WithClientOptions(opts...), ), unsubscribe: connect.NewClient[v1.UnsubscribeRequest, v1.Empty]( httpClient, baseURL+NostrRelayUnsubscribeProcedure, connect.WithSchema(nostrRelayMethods.ByName("Unsubscribe")), connect.WithClientOptions(opts...), ), publishBatch: connect.NewClient[v1.PublishBatchRequest, v1.PublishBatchResponse]( httpClient, baseURL+NostrRelayPublishBatchProcedure, connect.WithSchema(nostrRelayMethods.ByName("PublishBatch")), connect.WithClientOptions(opts...), ), queryEvents: connect.NewClient[v1.QueryRequest, v1.QueryResponse]( httpClient, baseURL+NostrRelayQueryEventsProcedure, connect.WithSchema(nostrRelayMethods.ByName("QueryEvents")), connect.WithClientOptions(opts...), ), countEvents: connect.NewClient[v1.CountRequest, v1.CountResponse]( httpClient, baseURL+NostrRelayCountEventsProcedure, connect.WithSchema(nostrRelayMethods.ByName("CountEvents")), connect.WithClientOptions(opts...), ), } } // nostrRelayClient implements NostrRelayClient. type nostrRelayClient struct { publishEvent *connect.Client[v1.PublishEventRequest, v1.PublishEventResponse] subscribe *connect.Client[v1.SubscribeRequest, v1.Event] unsubscribe *connect.Client[v1.UnsubscribeRequest, v1.Empty] publishBatch *connect.Client[v1.PublishBatchRequest, v1.PublishBatchResponse] queryEvents *connect.Client[v1.QueryRequest, v1.QueryResponse] countEvents *connect.Client[v1.CountRequest, v1.CountResponse] } // PublishEvent calls nostr.v1.NostrRelay.PublishEvent. func (c *nostrRelayClient) PublishEvent(ctx context.Context, req *connect.Request[v1.PublishEventRequest]) (*connect.Response[v1.PublishEventResponse], error) { return c.publishEvent.CallUnary(ctx, req) } // Subscribe calls nostr.v1.NostrRelay.Subscribe. func (c *nostrRelayClient) Subscribe(ctx context.Context, req *connect.Request[v1.SubscribeRequest]) (*connect.ServerStreamForClient[v1.Event], error) { return c.subscribe.CallServerStream(ctx, req) } // Unsubscribe calls nostr.v1.NostrRelay.Unsubscribe. func (c *nostrRelayClient) Unsubscribe(ctx context.Context, req *connect.Request[v1.UnsubscribeRequest]) (*connect.Response[v1.Empty], error) { return c.unsubscribe.CallUnary(ctx, req) } // PublishBatch calls nostr.v1.NostrRelay.PublishBatch. func (c *nostrRelayClient) PublishBatch(ctx context.Context, req *connect.Request[v1.PublishBatchRequest]) (*connect.Response[v1.PublishBatchResponse], error) { return c.publishBatch.CallUnary(ctx, req) } // QueryEvents calls nostr.v1.NostrRelay.QueryEvents. func (c *nostrRelayClient) QueryEvents(ctx context.Context, req *connect.Request[v1.QueryRequest]) (*connect.Response[v1.QueryResponse], error) { return c.queryEvents.CallUnary(ctx, req) } // CountEvents calls nostr.v1.NostrRelay.CountEvents. func (c *nostrRelayClient) CountEvents(ctx context.Context, req *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) { return c.countEvents.CallUnary(ctx, req) } // NostrRelayHandler is an implementation of the nostr.v1.NostrRelay service. type NostrRelayHandler interface { // Publish a single event PublishEvent(context.Context, *connect.Request[v1.PublishEventRequest]) (*connect.Response[v1.PublishEventResponse], error) // Subscribe to events matching filters (streaming) Subscribe(context.Context, *connect.Request[v1.SubscribeRequest], *connect.ServerStream[v1.Event]) error // Unsubscribe from an active subscription Unsubscribe(context.Context, *connect.Request[v1.UnsubscribeRequest]) (*connect.Response[v1.Empty], error) // gRPC-specific: batch publish PublishBatch(context.Context, *connect.Request[v1.PublishBatchRequest]) (*connect.Response[v1.PublishBatchResponse], error) // gRPC-specific: paginated query (non-streaming) QueryEvents(context.Context, *connect.Request[v1.QueryRequest]) (*connect.Response[v1.QueryResponse], error) // Event counts (NIP-45) CountEvents(context.Context, *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) } // NewNostrRelayHandler builds an HTTP handler from the service implementation. It returns the path // on which to mount the handler and the handler itself. // // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf // and JSON codecs. They also support gzip compression. func NewNostrRelayHandler(svc NostrRelayHandler, opts ...connect.HandlerOption) (string, http.Handler) { nostrRelayMethods := v1.File_nostr_v1_nostr_proto.Services().ByName("NostrRelay").Methods() nostrRelayPublishEventHandler := connect.NewUnaryHandler( NostrRelayPublishEventProcedure, svc.PublishEvent, connect.WithSchema(nostrRelayMethods.ByName("PublishEvent")), connect.WithHandlerOptions(opts...), ) nostrRelaySubscribeHandler := connect.NewServerStreamHandler( NostrRelaySubscribeProcedure, svc.Subscribe, connect.WithSchema(nostrRelayMethods.ByName("Subscribe")), connect.WithHandlerOptions(opts...), ) nostrRelayUnsubscribeHandler := connect.NewUnaryHandler( NostrRelayUnsubscribeProcedure, svc.Unsubscribe, connect.WithSchema(nostrRelayMethods.ByName("Unsubscribe")), connect.WithHandlerOptions(opts...), ) nostrRelayPublishBatchHandler := connect.NewUnaryHandler( NostrRelayPublishBatchProcedure, svc.PublishBatch, connect.WithSchema(nostrRelayMethods.ByName("PublishBatch")), connect.WithHandlerOptions(opts...), ) nostrRelayQueryEventsHandler := connect.NewUnaryHandler( NostrRelayQueryEventsProcedure, svc.QueryEvents, connect.WithSchema(nostrRelayMethods.ByName("QueryEvents")), connect.WithHandlerOptions(opts...), ) nostrRelayCountEventsHandler := connect.NewUnaryHandler( NostrRelayCountEventsProcedure, svc.CountEvents, connect.WithSchema(nostrRelayMethods.ByName("CountEvents")), connect.WithHandlerOptions(opts...), ) return "/nostr.v1.NostrRelay/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case NostrRelayPublishEventProcedure: nostrRelayPublishEventHandler.ServeHTTP(w, r) case NostrRelaySubscribeProcedure: nostrRelaySubscribeHandler.ServeHTTP(w, r) case NostrRelayUnsubscribeProcedure: nostrRelayUnsubscribeHandler.ServeHTTP(w, r) case NostrRelayPublishBatchProcedure: nostrRelayPublishBatchHandler.ServeHTTP(w, r) case NostrRelayQueryEventsProcedure: nostrRelayQueryEventsHandler.ServeHTTP(w, r) case NostrRelayCountEventsProcedure: nostrRelayCountEventsHandler.ServeHTTP(w, r) default: http.NotFound(w, r) } }) } // UnimplementedNostrRelayHandler returns CodeUnimplemented from all methods. type UnimplementedNostrRelayHandler struct{} func (UnimplementedNostrRelayHandler) PublishEvent(context.Context, *connect.Request[v1.PublishEventRequest]) (*connect.Response[v1.PublishEventResponse], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.PublishEvent is not implemented")) } func (UnimplementedNostrRelayHandler) Subscribe(context.Context, *connect.Request[v1.SubscribeRequest], *connect.ServerStream[v1.Event]) error { return connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.Subscribe is not implemented")) } func (UnimplementedNostrRelayHandler) Unsubscribe(context.Context, *connect.Request[v1.UnsubscribeRequest]) (*connect.Response[v1.Empty], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.Unsubscribe is not implemented")) } func (UnimplementedNostrRelayHandler) PublishBatch(context.Context, *connect.Request[v1.PublishBatchRequest]) (*connect.Response[v1.PublishBatchResponse], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.PublishBatch is not implemented")) } func (UnimplementedNostrRelayHandler) QueryEvents(context.Context, *connect.Request[v1.QueryRequest]) (*connect.Response[v1.QueryResponse], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.QueryEvents is not implemented")) } func (UnimplementedNostrRelayHandler) CountEvents(context.Context, *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.NostrRelay.CountEvents is not implemented")) } // RelayAdminClient is a client for the nostr.v1.RelayAdmin service. type RelayAdminClient interface { GetStats(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.RelayStats], error) GetConnections(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.ConnectionList], error) BanPublicKey(context.Context, *connect.Request[v1.BanRequest]) (*connect.Response[v1.Empty], error) GetStorageInfo(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.StorageStats], error) } // NewRelayAdminClient constructs a client for the nostr.v1.RelayAdmin service. By default, it uses // the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends // uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or // connect.WithGRPCWeb() options. // // The URL supplied here should be the base URL for the Connect or gRPC server (for example, // http://api.acme.com or https://acme.com/grpc). func NewRelayAdminClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) RelayAdminClient { baseURL = strings.TrimRight(baseURL, "/") relayAdminMethods := v1.File_nostr_v1_nostr_proto.Services().ByName("RelayAdmin").Methods() return &relayAdminClient{ getStats: connect.NewClient[v1.Empty, v1.RelayStats]( httpClient, baseURL+RelayAdminGetStatsProcedure, connect.WithSchema(relayAdminMethods.ByName("GetStats")), connect.WithClientOptions(opts...), ), getConnections: connect.NewClient[v1.Empty, v1.ConnectionList]( httpClient, baseURL+RelayAdminGetConnectionsProcedure, connect.WithSchema(relayAdminMethods.ByName("GetConnections")), connect.WithClientOptions(opts...), ), banPublicKey: connect.NewClient[v1.BanRequest, v1.Empty]( httpClient, baseURL+RelayAdminBanPublicKeyProcedure, connect.WithSchema(relayAdminMethods.ByName("BanPublicKey")), connect.WithClientOptions(opts...), ), getStorageInfo: connect.NewClient[v1.Empty, v1.StorageStats]( httpClient, baseURL+RelayAdminGetStorageInfoProcedure, connect.WithSchema(relayAdminMethods.ByName("GetStorageInfo")), connect.WithClientOptions(opts...), ), } } // relayAdminClient implements RelayAdminClient. type relayAdminClient struct { getStats *connect.Client[v1.Empty, v1.RelayStats] getConnections *connect.Client[v1.Empty, v1.ConnectionList] banPublicKey *connect.Client[v1.BanRequest, v1.Empty] getStorageInfo *connect.Client[v1.Empty, v1.StorageStats] } // GetStats calls nostr.v1.RelayAdmin.GetStats. func (c *relayAdminClient) GetStats(ctx context.Context, req *connect.Request[v1.Empty]) (*connect.Response[v1.RelayStats], error) { return c.getStats.CallUnary(ctx, req) } // GetConnections calls nostr.v1.RelayAdmin.GetConnections. func (c *relayAdminClient) GetConnections(ctx context.Context, req *connect.Request[v1.Empty]) (*connect.Response[v1.ConnectionList], error) { return c.getConnections.CallUnary(ctx, req) } // BanPublicKey calls nostr.v1.RelayAdmin.BanPublicKey. func (c *relayAdminClient) BanPublicKey(ctx context.Context, req *connect.Request[v1.BanRequest]) (*connect.Response[v1.Empty], error) { return c.banPublicKey.CallUnary(ctx, req) } // GetStorageInfo calls nostr.v1.RelayAdmin.GetStorageInfo. func (c *relayAdminClient) GetStorageInfo(ctx context.Context, req *connect.Request[v1.Empty]) (*connect.Response[v1.StorageStats], error) { return c.getStorageInfo.CallUnary(ctx, req) } // RelayAdminHandler is an implementation of the nostr.v1.RelayAdmin service. type RelayAdminHandler interface { GetStats(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.RelayStats], error) GetConnections(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.ConnectionList], error) BanPublicKey(context.Context, *connect.Request[v1.BanRequest]) (*connect.Response[v1.Empty], error) GetStorageInfo(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.StorageStats], error) } // NewRelayAdminHandler builds an HTTP handler from the service implementation. It returns the path // on which to mount the handler and the handler itself. // // By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf // and JSON codecs. They also support gzip compression. func NewRelayAdminHandler(svc RelayAdminHandler, opts ...connect.HandlerOption) (string, http.Handler) { relayAdminMethods := v1.File_nostr_v1_nostr_proto.Services().ByName("RelayAdmin").Methods() relayAdminGetStatsHandler := connect.NewUnaryHandler( RelayAdminGetStatsProcedure, svc.GetStats, connect.WithSchema(relayAdminMethods.ByName("GetStats")), connect.WithHandlerOptions(opts...), ) relayAdminGetConnectionsHandler := connect.NewUnaryHandler( RelayAdminGetConnectionsProcedure, svc.GetConnections, connect.WithSchema(relayAdminMethods.ByName("GetConnections")), connect.WithHandlerOptions(opts...), ) relayAdminBanPublicKeyHandler := connect.NewUnaryHandler( RelayAdminBanPublicKeyProcedure, svc.BanPublicKey, connect.WithSchema(relayAdminMethods.ByName("BanPublicKey")), connect.WithHandlerOptions(opts...), ) relayAdminGetStorageInfoHandler := connect.NewUnaryHandler( RelayAdminGetStorageInfoProcedure, svc.GetStorageInfo, connect.WithSchema(relayAdminMethods.ByName("GetStorageInfo")), connect.WithHandlerOptions(opts...), ) return "/nostr.v1.RelayAdmin/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { switch r.URL.Path { case RelayAdminGetStatsProcedure: relayAdminGetStatsHandler.ServeHTTP(w, r) case RelayAdminGetConnectionsProcedure: relayAdminGetConnectionsHandler.ServeHTTP(w, r) case RelayAdminBanPublicKeyProcedure: relayAdminBanPublicKeyHandler.ServeHTTP(w, r) case RelayAdminGetStorageInfoProcedure: relayAdminGetStorageInfoHandler.ServeHTTP(w, r) default: http.NotFound(w, r) } }) } // UnimplementedRelayAdminHandler returns CodeUnimplemented from all methods. type UnimplementedRelayAdminHandler struct{} func (UnimplementedRelayAdminHandler) GetStats(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.RelayStats], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.RelayAdmin.GetStats is not implemented")) } func (UnimplementedRelayAdminHandler) GetConnections(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.ConnectionList], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.RelayAdmin.GetConnections is not implemented")) } func (UnimplementedRelayAdminHandler) BanPublicKey(context.Context, *connect.Request[v1.BanRequest]) (*connect.Response[v1.Empty], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.RelayAdmin.BanPublicKey is not implemented")) } func (UnimplementedRelayAdminHandler) GetStorageInfo(context.Context, *connect.Request[v1.Empty]) (*connect.Response[v1.StorageStats], error) { return nil, connect.NewError(connect.CodeUnimplemented, errors.New("nostr.v1.RelayAdmin.GetStorageInfo is not implemented")) }