Skip to content

Instantly share code, notes, and snippets.

@karthikraobr
Last active September 29, 2023 13:14
Show Gist options
  • Save karthikraobr/4b11dac882cc88624f985d3bd66707f9 to your computer and use it in GitHub Desktop.
Save karthikraobr/4b11dac882cc88624f985d3bd66707f9 to your computer and use it in GitHub Desktop.
sequence diagram

promotion event handling

sequenceDiagram
    participant e as engine
    participant p as promotion
    participant d as pricing-db
    p->>e: event: promotion was created
    e->>p: grpc: get latest promotion <br/>/discount by ID
    p->>e: grpc: latest promotion by ID
    e->>d: query: get affected products <br/> with properties
    e->>d: query: prices having the same scope <br/>(market+hub+validity)
    alt yes
    e->>d: query: update the above row with the new price and discount id
    else no
    e->>d: query: insert a new price for that product
    end
Loading

tier assignment create/update

sequenceDiagram
    participant e as engine
    participant p as promotion
    participant d as pricing-db
    participant h as pubsub

    h->>e:1:event: assignment was created/updated.
    e->>d:2:query: fetch latest version of the assignment.
    e->>d:3:query: fetch latest version of the strategy<br/>of the asignment.
    e->>d:4:query: fetch all products along with properties<br/>belonging to the market of the assignment.
    e->>d:5:query: fetch stepping rules of the strategy <br/> along with their rounding rules.
    e->>p:6:grpc: get discounts for all affected products<br/>market and hub combo<br/>(concurrent fetch per hub).
    e->>d:7:query: fetch all prices for products belonging <br/> to the hubs of the market including<br/> discounted prices.
    e->>e:8:calculate tier prices based on tier formula.
    e->>d:9:query:update/insert tier prices.
    e->>e:10:calculcate discounted price from <br/> discounts in step 6.
    alt if step 7 contains discounted prices<br/>(match discount id from price in step 7 and discount in step 6)
    e->>d:11:query:update discounted prices
    else
    e->>d:12:query:insert discounted prices
    end
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment