MCPcopy Create free account
hub / github.com/erpc/erpc / ProcessQueryStream

Method ProcessQueryStream

erpc/request_processor.go:69–147  ·  view source on GitHub ↗
(
	ctx context.Context,
	input *RequestInput,
	queryReq proto.Message,
	onPage func(proto.Message) error,
)

Source from the content-addressed store, hash-verified

67}
68
69func (rp *RequestProcessor) ProcessQueryStream(
70 ctx context.Context,
71 input *RequestInput,
72 queryReq proto.Message,
73 onPage func(proto.Message) error,
74) error {
75 start := time.Now()
76 ctx, span := common.StartSpan(ctx, "QueryStream.Handle")
77 defer span.End()
78
79 project, err := rp.erpc.GetProject(input.ProjectId)
80 if err != nil {
81 common.SetTraceSpanError(span, err)
82 return err
83 }
84
85 method := queryMethodFromProto(queryReq)
86 networkID := fmt.Sprintf("%s:%s", input.Architecture, input.ChainId)
87
88 span.SetAttributes(
89 attribute.String("query.method", method),
90 attribute.String("project.id", input.ProjectId),
91 attribute.String("network.id", networkID),
92 )
93
94 lg := rp.logger.With().
95 Str("component", "queryStream").
96 Str("projectId", input.ProjectId).
97 Str("networkId", networkID).
98 Str("method", method).
99 Str("clientIP", input.ClientIP).
100 Logger()
101
102 lg.Info().Msgf("processing query stream request")
103
104 nq := common.NewNormalizedRequestFromJsonRpcRequest(
105 common.NewJsonRpcRequest(method, []interface{}{}),
106 )
107 nq.SetClientIP(input.ClientIP)
108 if input.UserAgent != "" {
109 nq.SetAgentName(input.UserAgent)
110 }
111
112 user, err := project.AuthenticateConsumer(ctx, nq, method, input.AuthPayload)
113 if err != nil {
114 lg.Debug().Err(err).Msgf("query stream authentication failed")
115 common.SetTraceSpanError(span, err)
116 return err
117 }
118 nq.SetUser(user)
119
120 network, err := project.GetNetwork(ctx, networkID)
121 if err != nil {
122 lg.Debug().Err(err).Msgf("failed to resolve network for query stream")
123 common.SetTraceSpanError(span, err)
124 return err
125 }
126 nq.SetNetwork(network)

Callers 6

QueryBlocksMethod · 0.80
QueryTransactionsMethod · 0.80
QueryLogsMethod · 0.80
QueryTracesMethod · 0.80
QueryTransfersMethod · 0.80

Calls 15

ExecuteMethod · 0.95
StartSpanFunction · 0.92
SetTraceSpanErrorFunction · 0.92
NewJsonRpcRequestFunction · 0.92
queryMethodFromProtoFunction · 0.85
NewEvmQueryExecutorFunction · 0.85
EndMethod · 0.80
SetAttributesMethod · 0.80
SetClientIPMethod · 0.80
SetAgentNameMethod · 0.80
AuthenticateConsumerMethod · 0.80