enterprise scheduling with haskell
play

ENTERPRISE SCHEDULING WITH HASKELL Ryan Trinkle, CTO skedge.me - PowerPoint PPT Presentation

ENTERPRISE SCHEDULING WITH HASKELL Ryan Trinkle, CTO skedge.me Saturday, November 30, 13 SKEDGE.ME Cloud-based scheduling platform Clients Branded customer experience Sephora Flexible business workflow Tiffany Deep


  1. ENTERPRISE SCHEDULING WITH HASKELL Ryan Trinkle, CTO skedge.me Saturday, November 30, 13

  2. SKEDGE.ME • Cloud-based scheduling platform • Clients • Branded customer experience • Sephora • Flexible business workflow • Tiffany • Deep integration • Stanford • Backend-systems • FBI • In-store workflow (iPad, etc.) • ... Saturday, November 30, 13

  3. Saturday, November 30, 13

  4. Saturday, November 30, 13

  5. PROBLEM • 43,000 lines of Groovy on Grails • Poorly documented • Major, intractable bugs • Bad performance • Timezones • Inflexible • Recurring events • Notifications • Double-booking Saturday, November 30, 13

  6. ARCHITECTURE General-purp l-purpose Clien lient-specific People Notifications ... BuyNLarge AcmeU ... Appointments Biz Business rules ules enforcement orcement Sec Authorization tion DB ADTs, CRUD, UD, caching, valida alidation RawDB ACID transact sactions, no side ef side effects, automa tomatic ret ic retries IO Basic Haskell - skell - unsafe side ef side effects; anything ything goes oes Saturday, November 30, 13

  7. ARCHITECTURE General-purp l-purpose Clien lient-specific People Notifications ... BuyNLarge AcmeU ... Appointments Biz Sec DB RawDB IO Saturday, November 30, 13

  8. SECURITY • Roles by client • Basic: Owner, Staff, Customer • BuyNLarge: Leadership, District Manager, Store Manager, Sales Associate, Customer • AcmeU: Admin, Faculty, Staff, Teaching Assistant, Student Saturday, November 30, 13

  9. SECURITY • Verbs by component • Appointment: Book, Join, Reschedule, Cancel, Delete • People: Create, Read, Update, Delete • Notifications: Send, Edit, Cancel, etc. • BuyNLarge Reports: Run District Report, Run Store Report Saturday, November 30, 13

  10. SECURITY class Policy role verb where isAuthorized :: role -> verb -> DB Bool Saturday, November 30, 13

  11. SECURITY instance Policy BNLRole BNLReportVerb where isAuthorized BNLLeadership _ = return True isAuthorized (BNLDistrictManager dist) a = case a of BNLRunDistrictReport dist’ -> return (dist == dist’) BNLRunStoreReport store -> return (storeDistrict store == dist) isAuthorized (BNLStoreManager store) a = case a of BNLRunStoreReport store’ -> return (store == store’) _ -> return False isAuthorized _ _ = return False Saturday, November 30, 13

  12. SECURITY General-purp l-purpose Clien lient-specific People Notifications ... BuyNLarge AcmeU ... Appointments Standard BuyNLarge AcmeU ... Saturday, November 30, 13

  13. SECURITY instance Policy BNLRole AppointmentVerb where isAuthorized r = isAuthorized $ case r of BNLLeadership -> StandardAdmin BNLDistrictManager _ -> StandardStaff BNLStoreManager _ -> StandardStaff BNLCustomer -> StandardCustomer Saturday, November 30, 13

  14. SECURITY General-purp l-purpose Clien lient-specific People Notifications ... BuyNLarge AcmeU ... Appointments Standard BuyNLarge AcmeU ... Saturday, November 30, 13

  15. QUICK-AND-DIRTY IMPORTER • Limited set of inputs • “End-user” is our developers • Thrown away when job is done Saturday, November 30, 13

  16. QUICK-AND-DIRTY IMPORTER • 1400 lines of Haskell • Never refactored • Lots of partiality • Lots weirdly-specific, huge functions • Leans heavily on type system Saturday, November 30, 13

  17. QUICK-AND-DIRTY IMPORTER importService :: EventNotificationPolicy -> (Maybe Bool -> Map (Ref ThingField) FieldProperties) -> (Maybe Bool -> Map (Ref AttendeeField) FieldProperties) -> Ref ThingField -> Ref ThingField -> Ref ThingField -> Ref ThingField -> Ref AttendeeField -> Ref AttendeeField -> Ref ServiceField -> Ref ServiceField -> Ref ServiceField -> Ref Role -> Ref Role -> Ref Role -> Ref (Constraint (Ref Thing)) -> (Text -> Ref Thing) -> (Text -> Ref Thing) -> (Text -> Maybe (Ref AttendeeField, CustomAttendeeField)) -> S1.Service -> DB (Ref Sk.Service) Saturday, November 30, 13

  18. LIBRARIES • Javascript: 9 libraries • Haskell: 71 libraries + 87 dependencies Saturday, November 30, 13

  19. LIBRARIES • Haskell libraries tend to be • Easier to find • Easier to vet • Higher quality Saturday, November 30, 13

  20. ANNOYANCES • Cyclic module dependencies with hs-boot files are unwieldy - avoid • Scalability above 4 cores is limited - apparently fixed in GHC 7.8 • Idle GC can cause issues - disable • Debugging production issues without stack traces is hard - consider using profiling Saturday, November 30, 13

  21. RESULT • 8,200 lines of Haskell • No persistent bugs • Greatly improved performance and flexibility • Used daily by thousands of people Saturday, November 30, 13

Recommend


More recommend