Skip to content

[ENG-3815] feat(microsoft): Impl Create Subscription#2878

Open
Cobalt0s wants to merge 1 commit into
cobalt0s/subscribe-scriptsfrom
cobalt0s/microsoft-subscribe-create
Open

[ENG-3815] feat(microsoft): Impl Create Subscription#2878
Cobalt0s wants to merge 1 commit into
cobalt0s/subscribe-scriptsfrom
cobalt0s/microsoft-subscribe-create

Conversation

@Cobalt0s
Copy link
Copy Markdown
Contributor

@Cobalt0s Cobalt0s commented Apr 14, 2026

Description

Implements Microsoft create-subscription support. Also, using the new scripting infrastructure, adds integration tests and unit tests.

Key changes

  • Subscription implementation
    Implements SubscriptionCreator using the subscriber strategy (this strategy will implement update & delete in subsequent PRs).

  • Microsoft-specific types
    Exports SubscribeRequest and SubscribeResponse for server integration.

  • Script integration
    Uses the new scripts to validate real scenarios:

    • Outlook Calendar: create/update/delete → receives only subscribed events (create + delete)
    • Outlook Messages: create/update/delete → receives all events (subscribed to create + update + delete)
  • Unit testing
    Adds testroutines.CreateSubscription for validating subscription creation logic.

  • Time abstraction
    Introduces components.Clock (RealClock and FixedClock) to support deterministic testing.

Live Tests

Outlook Calendar Events

Calendar events

Outlook Mail Messages

Outlook messages

@linear
Copy link
Copy Markdown

linear Bot commented Apr 14, 2026

@Cobalt0s Cobalt0s self-assigned this Apr 14, 2026
@Cobalt0s Cobalt0s force-pushed the cobalt0s/microsoft-webhook-verifier branch from 97fae5b to 50c6650 Compare May 1, 2026 00:11
@Cobalt0s Cobalt0s force-pushed the cobalt0s/microsoft-subscribe-create branch from 3b926aa to 1289e81 Compare May 1, 2026 00:11
@Cobalt0s Cobalt0s force-pushed the cobalt0s/microsoft-subscribe-create branch from 1289e81 to f145e5c Compare May 1, 2026 15:33
@Cobalt0s Cobalt0s force-pushed the cobalt0s/microsoft-webhook-verifier branch from 50c6650 to 92c0bef Compare May 1, 2026 15:33
@Cobalt0s Cobalt0s changed the base branch from cobalt0s/microsoft-webhook-verifier to graphite-base/2878 May 1, 2026 17:32
@Cobalt0s Cobalt0s force-pushed the graphite-base/2878 branch from 92c0bef to bfa981f Compare May 1, 2026 17:33
@Cobalt0s Cobalt0s force-pushed the cobalt0s/microsoft-subscribe-create branch from f145e5c to f9b7354 Compare May 1, 2026 17:33
Comment thread .gitignore
subscribe
subscriber
./subscribe
./subscriber
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure what is the reason for ignoring these and where exactly this data is stored. The directory names are good and shouldn't be excluded.

@Cobalt0s Cobalt0s force-pushed the graphite-base/2878 branch from bfa981f to d3bd6c1 Compare May 1, 2026 21:58
@Cobalt0s Cobalt0s force-pushed the cobalt0s/microsoft-subscribe-create branch from f9b7354 to 920f377 Compare May 1, 2026 21:58
@Cobalt0s Cobalt0s marked this pull request as ready for review May 1, 2026 21:59
Copy link
Copy Markdown
Contributor

@jlimatampersand jlimatampersand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are too many unnecessary structs and functions that are beyond the scope of what is necessary to implement Subscribe.

Please remember this is an open-source project that many different contributors with various experiences and familiarity contribute to.

Any new introduction of internal packages and data utils becomes an immediate huddle and a learning curve for every contributor, making onboarding harder and adding complexity.

Please try using native packages unless you really need to use wrapper packages.

//
// It uses a mock HTTP client and overrides the base URL to point to a test server.
// A fixed clock is injected to ensure deterministic behavior in tests.
func constructTestStrategy(serverURL string) (*Strategy, error) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be in test folder

}

return &common.SubscriptionResult{
Result: Output{},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to have an empty struct type as a placeholder. Result type is any, so we don't even need to populate it as it will default to nil.

// It is part of the connector's input/output contract: the caller expresses intent
// with State, and the connector returns the same type reflecting what actually
// happened (which may differ on failure or rollback).
State map[ObjectName]common.ObjectEvents
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this wrapper layer needed? Unless there is a strong reason, I would like to keep each provider addition to a minimal context. There is no new variable, method, defined for this State struct, so I would remove this.


// Clock provides the current time, enabling deterministic testing of time-dependent logic.
// Implementations include production (real time) and test (fixed time) variants.
type Clock interface {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am strongly against adding new components that are just wrappers of native packages.

This only introduces onboarding complexity and load.

Please remove this type and just the native package.

objectNames := datautils.FromMap(params.SubscriptionEvents).Keys()

return &common.SubscriptionResult{
Result: Output{},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nil is sufficient. or just leave it empty.

Right R
}

func NewPair[L, R any](left L, right R) *Pair[L, R] {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary util func. Please remove.


// Dependent services.
batchStrategy *batch.Strategy
clock components.Clock
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this necessary? if this is just useful for testing, I would just opt for the native time package.

@Cobalt0s Cobalt0s force-pushed the graphite-base/2878 branch from d3bd6c1 to de29855 Compare May 13, 2026 21:33
@Cobalt0s Cobalt0s force-pushed the cobalt0s/microsoft-subscribe-create branch from 920f377 to 8adbb04 Compare May 13, 2026 21:33
@Cobalt0s Cobalt0s changed the base branch from graphite-base/2878 to cobalt0s/subscribe-scripts May 13, 2026 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants