From 3a5dd96a953df4b5687244c28cfbbe3103a303bd Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 6 Jun 2023 18:44:24 -0700 Subject: [PATCH] pricesrpc: add http_request_text to GetPrice In this commit, we add the http_request_text to the `GetPrice` RPC call. This'll contain the fully serialized HTTP request, which'll permit the back end to check things like the set of headers or request body, which may be useful in more fine grained pricing functions. One example is: when proxying requests to an LLM platform provider, the backed may want to charge more based on the length of the context/message and/or which model is being used. --- pricesrpc/rpc.pb.go | 41 ++++++++++++++++++++++++-------------- pricesrpc/rpc.proto | 6 +++++- pricesrpc/rpc.swagger.json | 3 +++ 3 files changed, 34 insertions(+), 16 deletions(-) diff --git a/pricesrpc/rpc.pb.go b/pricesrpc/rpc.pb.go index c3afc74..4b137d8 100644 --- a/pricesrpc/rpc.pb.go +++ b/pricesrpc/rpc.pb.go @@ -25,7 +25,8 @@ type GetPriceRequest struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"` + HttpRequestText string `protobuf:"bytes,2,opt,name=http_request_text,json=httpRequestText,proto3" json:"http_request_text,omitempty"` } func (x *GetPriceRequest) Reset() { @@ -67,6 +68,13 @@ func (x *GetPriceRequest) GetPath() string { return "" } +func (x *GetPriceRequest) GetHttpRequestText() string { + if x != nil { + return x.HttpRequestText + } + return "" +} + type GetPriceResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -118,21 +126,24 @@ var File_rpc_proto protoreflect.FileDescriptor var file_rpc_proto_rawDesc = []byte{ 0x0a, 0x09, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x09, 0x70, 0x72, 0x69, - 0x63, 0x65, 0x73, 0x72, 0x70, 0x63, 0x22, 0x25, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, + 0x63, 0x65, 0x73, 0x72, 0x70, 0x63, 0x22, 0x51, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, - 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x22, 0x31, 0x0a, - 0x10, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x70, 0x72, 0x69, 0x63, 0x65, 0x5f, 0x73, 0x61, 0x74, 0x73, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x70, 0x72, 0x69, 0x63, 0x65, 0x53, 0x61, 0x74, 0x73, - 0x32, 0x4d, 0x0a, 0x06, 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x43, 0x0a, 0x08, 0x47, 0x65, - 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x72, - 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x72, 0x70, 0x63, 0x2e, 0x47, - 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, - 0x2d, 0x5a, 0x2b, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, - 0x67, 0x68, 0x74, 0x6e, 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x61, 0x70, 0x65, 0x72, - 0x74, 0x75, 0x72, 0x65, 0x2f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x72, 0x70, 0x63, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x2a, 0x0a, + 0x11, 0x68, 0x74, 0x74, 0x70, 0x5f, 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x5f, 0x74, 0x65, + 0x78, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x68, 0x74, 0x74, 0x70, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x54, 0x65, 0x78, 0x74, 0x22, 0x31, 0x0a, 0x10, 0x47, 0x65, 0x74, + 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, + 0x0a, 0x70, 0x72, 0x69, 0x63, 0x65, 0x5f, 0x73, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x09, 0x70, 0x72, 0x69, 0x63, 0x65, 0x53, 0x61, 0x74, 0x73, 0x32, 0x4d, 0x0a, 0x06, + 0x50, 0x72, 0x69, 0x63, 0x65, 0x73, 0x12, 0x43, 0x0a, 0x08, 0x47, 0x65, 0x74, 0x50, 0x72, 0x69, + 0x63, 0x65, 0x12, 0x1a, 0x2e, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x72, 0x70, 0x63, 0x2e, 0x47, + 0x65, 0x74, 0x50, 0x72, 0x69, 0x63, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, + 0x2e, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x50, 0x72, + 0x69, 0x63, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, 0x2d, 0x5a, 0x2b, 0x67, + 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x6c, 0x69, 0x67, 0x68, 0x74, 0x6e, + 0x69, 0x6e, 0x67, 0x6c, 0x61, 0x62, 0x73, 0x2f, 0x61, 0x70, 0x65, 0x72, 0x74, 0x75, 0x72, 0x65, + 0x2f, 0x70, 0x72, 0x69, 0x63, 0x65, 0x73, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/pricesrpc/rpc.proto b/pricesrpc/rpc.proto index 2b81437..d11977d 100644 --- a/pricesrpc/rpc.proto +++ b/pricesrpc/rpc.proto @@ -6,6 +6,10 @@ option go_package = "github.com/lightninglabs/aperture/pricesrpc"; service Prices { rpc GetPrice(GetPriceRequest) returns (GetPriceResponse); } -message GetPriceRequest { string path = 1; } +message GetPriceRequest { + string path = 1; + + string http_request_text = 2; +} message GetPriceResponse { int64 price_sats = 1; } diff --git a/pricesrpc/rpc.swagger.json b/pricesrpc/rpc.swagger.json index 9e153a4..e12c09f 100644 --- a/pricesrpc/rpc.swagger.json +++ b/pricesrpc/rpc.swagger.json @@ -55,6 +55,9 @@ "properties": { "path": { "type": "string" + }, + "http_request_text": { + "type": "string" } } },