{"action":"created","issue":{"url":"https://api.github.com/repos/coduno/api/issues/42","labels_url":"https://api.github.com/repos/coduno/api/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/coduno/api/issues/42/comments","events_url":"https://api.github.com/repos/coduno/api/issues/42/events","html_url":"https://github.com/coduno/api/issues/42","id":100045863,"number":42,"title":"Define Logic","user":{"login":"flowlo","id":542154,"avatar_url":"https://avatars.githubusercontent.com/u/542154?v=3","gravatar_id":"","url":"https://api.github.com/users/flowlo","html_url":"https://github.com/flowlo","followers_url":"https://api.github.com/users/flowlo/followers","following_url":"https://api.github.com/users/flowlo/following{/other_user}","gists_url":"https://api.github.com/users/flowlo/gists{/gist_id}","starred_url":"https://api.github.com/users/flowlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/flowlo/subscriptions","organizations_url":"https://api.github.com/users/flowlo/orgs","repos_url":"https://api.github.com/users/flowlo/repos","events_url":"https://api.github.com/users/flowlo/events{/privacy}","received_events_url":"https://api.github.com/users/flowlo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/coduno/api/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/coduno/api/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-08-10T11:51:02Z","updated_at":"2015-08-10T14:39:35Z","closed_at":null,"body":"We [currently ](https://github.com/coduno/api/blob/cc60e1015851fe4e25346218cfeaff15bb14b4f7/model/logic.go) lack a definition of `model.Logic`.\r\n\r\nI thought of a way on how we could add modular logic blocks to our API without sacrificing much. The idea comes from `crypto`.\r\n\r\n * An exported function `RegisterLogic`, analogous to [`crypto.RegisterHash`](https://golang.org/pkg/crypto/#RegisterHash) in some package (like `github.com/coduno/api/logic`) in this repository. It will just build a custom \"function table\".\r\n * A predefined interface, analogous to ([`hash.Hash`](https://golang.org/pkg/hash/#Hash)) that every `Logic` has to offer.\r\n * Every implementation of logic calls `logic.Register` in it's `init()`. Those implementations can live inside this repository, or in private ones.\r\n * `Logic` can be instantiated as needed.\r\n * If some `Logic` is not linked, we `panic`.\r\n\r\nThis way, we can write our logic blocks in Go witth nearly no cuts in performance, and can keep them private if needed.\r\n\r\nOne drawback certainly is that we cannot magically add new `Logic` or types of logic at runtime.\r\n\r\nComments requested."},"comment":{"url":"https://api.github.com/repos/coduno/api/issues/comments/129477369","html_url":"https://github.com/coduno/api/issues/42#issuecomment-129477369","issue_url":"https://api.github.com/repos/coduno/api/issues/42","id":129477369,"user":{"login":"victorbalan","id":9076766,"avatar_url":"https://avatars.githubusercontent.com/u/9076766?v=3","gravatar_id":"","url":"https://api.github.com/users/victorbalan","html_url":"https://github.com/victorbalan","followers_url":"https://api.github.com/users/victorbalan/followers","following_url":"https://api.github.com/users/victorbalan/following{/other_user}","gists_url":"https://api.github.com/users/victorbalan/gists{/gist_id}","starred_url":"https://api.github.com/users/victorbalan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/victorbalan/subscriptions","organizations_url":"https://api.github.com/users/victorbalan/orgs","repos_url":"https://api.github.com/users/victorbalan/repos","events_url":"https://api.github.com/users/victorbalan/events{/privacy}","received_events_url":"https://api.github.com/users/victorbalan/received_events","type":"User","site_admin":false},"created_at":"2015-08-10T14:39:35Z","updated_at":"2015-08-10T14:39:35Z","body":"This is ok\r\n```go\r\nfunc Logic interface {\r\n\tCompute(key *datastore.Key) model.Skills\r\n}\r\n```\r\n\r\nThe key can be either task or result key. We can do a switch on the kind so we have just one Logic interface. For result it will just make the average of the tasks skill values and for the task we`ll figure out some formulas to calculate the skills. Would this make sense?"}}