Draft
Conversation
- Add eventEnabled field to Datasource struct - Add EnableEvent(), DisableEvent(), and IsEventEnabled() methods - Update OnEvent() to automatically enable events when callback is set - Update dispatch_event() to check eventEnabled independently - Refactor inspect() to decouple inspector logic from event dispatching - Refactor inspectQuery() to check both IsInspectEnabled() and IsEventEnabled() Co-authored-by: pnguyen215 <39581473+pnguyen215@users.noreply.github.com>
- Test event system works independently from inspector - Test inspector system works independently from events - Test both systems work together - Test Enable/Disable event methods - Test inspectQuery with different configurations - Test OnEvent with nil callback Co-authored-by: pnguyen215 <39581473+pnguyen215@users.noreply.github.com>
- Document the independence between event and inspector systems - Provide usage examples for all scenarios - Include migration guide from old workarounds - Explain performance considerations - Document backward compatibility guarantees Co-authored-by: pnguyen215 <39581473+pnguyen215@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix dependency issue in OnEvent for EventQueryInspect
Decouple event system from inspector system
Dec 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OnEvent()withEventQueryInspectonly fired when an inspector was registered, coupling two independent subsystems. This forced users to set up dummy inspectors just to receive query events.Changes
Core decoupling
eventEnabledfield toDatasource- tracks event system state independently frominspectEnabledOnEvent()now auto-enables events when callback is set (and disables when nil)dispatch_event()checkseventEnabledflag, returns early if disabledinspect()always createsQueryInspectand dispatches events regardless of inspector stateinspectQuery()tracks timing when either system is enabled (not just inspector)New API methods
EnableEvent(),DisableEvent(),IsEventEnabled()- explicit control over event systemUsage
Both systems now operate independently while remaining fully backward compatible.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
filippo.io/update-job-proxy /update-job-proxy sorg/loggy(dns block)/update-job-proxy /update-job-proxy -s 172.18.0.0/16 -j DROP JCA_Global_Root_CA2.pem /opt/hostedtoolcache/go/1.24.10//usr/share/ca-certificates/mozilla/Buypass_Class_2_Root_CA.crt abb0a7f8b3b8a9820012222801583815154/log.json -unreachable=falbash /tmp/go-build326/usr/bin/runc(dns block)gopkg.in/update-job-proxy /update-job-proxy sorg/loggy(dns block)/update-job-proxy /update-job-proxy -s 172.18.0.0/16 -j DROP JCA_Global_Root_CA2.pem /opt/hostedtoolcache/go/1.24.10//usr/share/ca-certificates/mozilla/Buypass_Class_2_Root_CA.crt abb0a7f8b3b8a9820012222801583815154/log.json -unreachable=falbash /tmp/go-build326/usr/bin/runc(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
Vấn đề hiện tại
Hiện tại,
OnEvent()vớiEventQueryInspectchỉ hoạt động khi có inspector được đăng ký quaOnInspector()hoặcSetInspector(). Điều này gây ra sự phụ thuộc không cần thiết giữa hai cơ chế.Root cause
Trong file
pgc.go, functioninspect()kiểm traIsInspectEnabled()ngay từ đầu:Và trong
inspectQuery():Điều này có nghĩa là nếu chỉ gọi
OnEvent()mà không set inspector, event sẽ không được dispatch.Yêu cầu thay đổi
1. Thêm flag riêng biệt cho event system
Trong
types.go, thêm field mới trong structDatasource:2. Thêm methods để bật/tắt event system
Trong
builder.go, thêm các methods:3. Cập nhật
OnEvent()để tự động enable event4. Cập nhật
dispatch_event()để kiểm tra eventEnabledTrong
pgc.go:5. Refactor
inspect()để tách biệt logic6. Refactor
inspectQuery()để luôn track timing khi event hoặc inspect enabled7. Đảm bảo backward compatibility
EnableInspect,DisableInspect,OnInspector,SetInspector) vẫn hoạt động như cũExpected behavior sau khi fix
Files cần sửa
types.go- Thêm fieldeventEnabledbuilder.go- Thêm methodsEnableEvent(),DisableEvent(),IsEventEnabled()và cập nhậtOnEvent()pgc.go- Cập nhậtdispatch_event(),inspect(),inspectQuery()This pull request was created as a result of the following prompt from Copilot chat.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.