github.com/corestoreio/csfw/util/naughtystrings

CoreStore: A standard library for e-commerce based on an optimized Magento 2 database structure. ⚠️ Under full development. DON'T use/test it! ⚠️


License
Apache-2.0
Install
go get github.com/corestoreio/csfw/util/naughtystrings

Documentation

CoreStore library WIP

WIP = Work in Progress

Build Status wercker status Appveyor Build status GoDoc Join the chat at https://gitter.im/corestoreio/csfw goreportcard

eCommerce library which is compatible to Magento 1 and 2 database schema.

Magento is a trademark of MAGENTO, INC..

Min. Go Version: 1.7

Usage

To properly use the CoreStore library some environment variables must be set before running go generate. (TODO)

Required settings

CS_DSN the environment variable for the MySQL connection.

$ export CS_DSN='magento1:magento1@tcp(localhost:3306)/magento1'
$ export CS_DSN='magento2:magento2@tcp(localhost:3306)/magento2'
$ go get github.com/corestoreio/csfw
$ export CS_DSN='see previous'
$ cd $GOPATH/src/github.com/corestoreio/csfw
$ go run codegen/tableToStruct/*.go

Testing

Setup two databases. One for Magento 1 and one for Magento 2 and fill them with the provided test data.

Create a DSN env var CS_DSN and point it to Magento 1 database. Run the tests. Change the env var to let it point to Magento 2 database. Rerun the tests.

Finding Allocations

Side note: There is a new testing approach: TBDD = Test n' Benchmark Driven Development.

On the first run we got this result:

$ go test -run=😶 -bench=Benchmark_WithInitStoreByToken .
PASS
Benchmark_WithInitStoreByToken-4      100000         17297 ns/op        9112 B/op        203 allocs/op
ok      github.com/corestoreio/csfw/store   2.569s

Quite shocking to use 203 allocs for just figuring out the current store view within a request.

Now compile your tests into an executable binary:

$ go test -c

This compilation reduces the noise in the below output trace log.

$ GODEBUG=allocfreetrace=1 ./store -test.run=😶 -test.bench=Benchmark_WithInitStoreByToken -test.benchtime=10ms 2>trace.log

Now open the trace.log file (around 26MB) and investigate all the allocations and refactor your code. Once finished you can achieve results like:

$ go test -run=😶  -bench=Benchmark_WithInitStoreByToken .
PASS
Benchmark_WithInitStoreByToken-4     2000000           826 ns/op         128 B/op          5 allocs/op
ok      github.com/corestoreio/csfw/store   2.569s

Other development helpers

TODO

  • Create Magento 1+2 modules to setup test database and test Magento system.

Contributing

Please have a look at the contribution guidelines.

Acknowledgements

Name Package License
Steve Francia cast MIT Copyright (c) 2014
Steve Francia bufferpool Simple Public License, V2.0
Jonathan Novak, Tyler Smith, Michal Bohuslávek dbr The MIT License (MIT) 2014
Martin Angers and Contributors. ctxthrottled The MIT License (MIT) 2014
Dave Cheney errors The MIT License (MIT) 2015
Jad Dittmar finance aka. money Copyright (c) 2011
Wenbin Xiao sqlparser Copyright 2015 BSD Style
Google Inc youtube/vitess\sqlparser Copyright 2012 BSD Style
Julien Schmidt ctxrouter aka. httprouter Copyright (c) 2013 MIT
Olivier Poitrey ctxmw.WithAccessLog & CORS Copyright (c) 2014-2015 MIT License
Dave Grijalva csjwt Copyright (c) 2012 MIT License

Licensing

CoreStore is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Copyright

Cyrill Schumacher - PGP Key