decathlon sport meeting - grails, a new sport discipline - greach'15

61
Decathlon Sport Meeting Alonso Torres, DEVELOPER Sports, a new Grails discipline Antonio de la Torre, DEVELOPER Kaleidos

Upload: antonio-de-la-torre-fernandez

Post on 15-Jul-2015

117 views

Category:

Technology


0 download

TRANSCRIPT

Decathlon Sport Meeting

Alonso Torres, DEVELOPER

Sports, a new Grails discipline

Antonio de la Torre, DEVELOPER

Kaleidos

Introduction

What’s Decathlon Sport Meeting?

Intro

Intro

Why want Decathlon to develop a Social Network?

● Decathlon’s mission is to make sports widely available

● Sport Meeting was created to take this one step further

Intro

Who developed it?

Kaleidos

What did it contributed to the community?

● 3 Pull Request to GrailsGRAILS-11647, GRAILS-11323, GRAILS-10763

● 6 open sourced plugins

Intro

Intro

How is DSM?

100k registered users

1000 active sport proposals

35 sports

Development Decisions

«The risk of a wrong decision is preferable to the terror of indecision.»

Maimónides (12th c.)

Development decisions

Divided in

three applications● WEB, JOBS, API

and a plugin with business

logic and common code● CORE

JOBS

WEB API

CORE

Development decisions

Command Objects

● Responsibility● Validate objects

○ accessing model to validate data

Development decisions

Command ObjectsCheck if is a type

and a valid domain object

Development decisions

Tests

● Start with Integration tests << due to odd behaviour

● and moving to Unit tests << less dependency

Development decisions

Asynchronous processes and background jobs

● Asynchronous processes (platform-core)

○ Immediate email sending

○ Push notifications to mobile devices

Development decisions

Asynchronous processes and background jobs

● Background jobs (quartz)

○ Quartz scheduler library

○ Tasks that are processed overnight■ Proposals clean up■ Mailing with interesting stuff (users, proposals)

API Decisions

API decisions

Trait with helpers to create responses: 4XX

API decisions

Command Objects accepts input JSON < Magic happens

API decisions

Command Objects accepts input JSON < Magic happens

API decisions

Command Objects accepts input JSON < Magic happens

Binding Lists

API decisions

Data Oriented Design (RESTful)

over

Screen Oriented Design

Infrastructure decisions

Infrastructure decisions

PostgreSQL as our main database

● Open-Source and very mature

● Highly scalability

● Widely used

Infrastructure decisions

MongoDB as a secondary storage for denormalized data

● Optimize read and searches by storing documents

● Filter, sorting, querying

● Highly availability

Infrastructure decisions

MongoDB to store statistics and usage data

● Fire and forget model

● Map-reduce to extract the information

Infrastructure decisions

MongoDB for geolocalized data

● Great support of geolocalization

● Aggregation pipeline

Infrastructure decisions

Terracotta as a Hibernate second-level cache and HTTP sessions

● Dual licensing (community and commercial)

● Problems scaling (on the community product)

● Decided to change to Redis

Infrastructure decisions

Releases upload to a Nexus repository

● Upload all the software revisions

● “release plugin” can manage this

● Could be easily automated for a continuous

delivery

Awesome Tools

«If I have seen further it is only by standing on the shoulders of giants.»

Isaac Newton

Awesome tools

Java Melody Plugin

● Allows monitoring of requests and JVM state

● Saved us in several occasions

Awesome tools

Build Test Data Plugin

● Creates complex objects from your constraints

Awesome tools

Build Test Data Plugin

● Creates complex objects from your constraints

Awesome tools

Build Test Data Plugin

● Creates complex objects from your constraints

Check constraints and relationships and creates the necessary objects

PostgresSQL Extensions plugin

Awesome tools

● Disclaimer: created by @ilopmar & @alotor inside

Kaleidos

● Provides native access to PSQL native types:

HSTORE, Arrays, JSON...

PostgresSQL Extensions plugin

Awesome tools

Awesome tools

Platform Core plugin

● Asynchronous task is a bliss

● Maintained by the Grails-core team

Awesome tools

Platform Core plugin

Know your tools

Awesome tools

GPars

● Easy parallelization inside the Groovy core

● Provides DSL’s and an easy API to parallelize

expensive tasks

● Sometimes difficult to work with GORM

Awesome tools

GPars

Awesome tools

GPars

Five threads at the same time

Awesome tools

GPars

we need a transaction within the new thread

Awesome tools

Groovy Metaprogramming

● Sometimes the magic is fun :)

● We developed a system with metaprogramming to

easily create new types of notification

Awesome tools

Awesome tools

Grails & Spring

● Problem: we wanted different implementations in

development and “real” environments

● Examples: notifications, file storage...

Awesome tools

Awesome tools

Inject a generic “fileService”

Awesome tools

Alias the necessary bean per environment

Difficult Challenges

Difficult Challenges

Migration Grails 2.1.5 → 2.4.4

Difficult Challenges

Migration Grails 2.1.5 → 2.4.4

● Upgrade Grails and it’s dependencies

● Package changes, API changes…

● DataBinding and Command objects changes

Difficult Challenges

URL’s internationalization

● Grails doesn’t support out-of-the-box multi-language URL’s

Difficult Challenges

Tests pollution

● With 1500+ tests if you’re polluting one of your

tests is a big issue

● If this happens to you check:

by @tednaleidhttp://bit.ly/1FlJs75

Difficult Challenges

API Documentation

● There is no easy way to keep an up-to-date API

documentation with Grails REST support

● Our solution: the documentation as GSP’s allow us to

reuse certain common part’s (like messages structure)

Difficult Challenges

MongoDB Plugin

● Mongodb’s GORM plugin had unexpected

behaviour

● We finally decided to use the low-level API when

accessing MongoDB

Going Forward

Going forward...

● Currently the application is only available for

spanish users

● Decathlon is present in 27 countries

Travel abroad!

Going forward...

● Decathlon Sport Meeting will be opening their API

● We hope to create an application ecosystem

around the social network

Opening the API

Going forward...

● First application using DSM API

● Was done during the ΠWEEK

Sport Spot

Going forward...

See you on track!