Skip to content

EventDispatcher自定义订阅 #32

@WUST-mengqinyu

Description

@WUST-mengqinyu

Feature Type

New API endpoint support

Problem Statement

这里好多订阅类型没支持,是不是可以至少支持用户自己实现EventHandler去订阅一个raw message
https://github.com/larksuite/oapi-sdk-go/tree/v3_main/event/dispatcher

Proposed Solution

fn register_raw<S: Into<String>,H: EventHandler>(mut self, key: S, handler: H) -> Result<Self, String>
    {
        let key = key.into();
        if self.processor_map.contains_key(&key) {
            return Err(format!("processor already registered, type: {key}"));
        }
        let processor = RawProcessorImpl::new(f);
        self.processor_map.insert(key, Box::new(handler));
        Ok(self)
    }

Alternatives Considered

No response

API Design (if applicable)

Use Case

struct MyEventHandle {}
    impl EventHandler for MyEventHandle {
        fn handle(&self, event: &Event) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
            Ok(())
        }
    }
    #[test]
    fn test_name() {
        let s = S;
        s.register_raw("raw", MyEventHandle {});
    }

Contribution

  • I'm willing to implement this feature
  • I'm willing to help with testing
  • I'm willing to help with documentation

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions