-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from themue/feature/example-#30
Merge base of cells example
- Loading branch information
Showing
15 changed files
with
378 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,5 @@ _testmain.go | |
*.swp | ||
|
||
# Editors | ||
.vscode | ||
.vscode | ||
example/coinalyzer/coinalyzer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Tideland Go Cells - Example - Behaviors - Documentation | ||
// | ||
// Copyright (C) 2010-2017 Frank Mueller / Tideland / Oldenburg / Germany | ||
// | ||
// All rights reserved. Use of this source code is governed | ||
// by the new BSD license. | ||
|
||
// Package behaviors contains the behaviors and the specializd | ||
// factory functions for the Tideland Go Cells example. | ||
package behaviors | ||
|
||
//EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Tideland Go Cells - Example - Behaviors - Global usable ones | ||
// | ||
// Copyright (C) 2010-2017 Frank Mueller / Tideland / Oldenburg / Germany | ||
// | ||
// All rights reserved. Use of this source code is governed | ||
// by the new BSD license. | ||
|
||
package behaviors | ||
|
||
//-------------------- | ||
// IMPORTS | ||
//-------------------- | ||
|
||
import ( | ||
"sync" | ||
"time" | ||
|
||
"github.com/tideland/gocells/behaviors" | ||
"github.com/tideland/gocells/cells" | ||
) | ||
|
||
//-------------------- | ||
// BEHAVIORS | ||
//-------------------- | ||
|
||
// MakeLogger returns a logger behavior. | ||
func MakeLogger() cells.Behavior { | ||
return behaviors.NewLoggerBehavior() | ||
} | ||
|
||
// MakeTicker returns a ticker for the clocking of the | ||
// emitting of the data. | ||
func MakeTicker() cells.Behavior { | ||
return behaviors.NewTickerBehavior(100 * time.Millisecond) | ||
} | ||
|
||
// MakeEndOFData returns a behavior reacting when all | ||
// data is done. | ||
func MakeEndOfData(wg sync.WaitGroup) cells.Behavior { | ||
wg.Add(1) | ||
return nil | ||
} | ||
|
||
// EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Tideland Go Cells - Example - Behaviors - Model | ||
// | ||
// Copyright (C) 2010-2017 Frank Mueller / Tideland / Oldenburg / Germany | ||
// | ||
// All rights reserved. Use of this source code is governed | ||
// by the new BSD license. | ||
|
||
package behaviors | ||
|
||
//-------------------- | ||
// IMPORTS | ||
//-------------------- | ||
|
||
//-------------------- | ||
// POPULATION | ||
//-------------------- | ||
|
||
// Population contains the population of a country or region | ||
// in one year. | ||
type Population struct { | ||
CountryName string | ||
CountryCode string | ||
Year string | ||
Value int | ||
} | ||
|
||
// Populations is the set of all populations. | ||
type Popoulations []Population | ||
|
||
// EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Tideland Go Cells - Example - Configuration | ||
// | ||
// Copyright (C) 2010-2017 Frank Mueller / Tideland / Oldenburg / Germany | ||
// | ||
// All rights reserved. Use of this source code is governed | ||
// by the new BSD license. | ||
|
||
package main | ||
|
||
//-------------------- | ||
// IMPORTS | ||
//-------------------- | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
//-------------------- | ||
// CONFIGURATION | ||
//-------------------- | ||
|
||
// Configuration contains the sewttings for the example application. | ||
type Configuration struct { | ||
} | ||
|
||
//-------------------- | ||
// CONTEXT | ||
//-------------------- | ||
|
||
// contextKey is used to type keys for context values. | ||
type contextKey int | ||
|
||
// configurationKey addresses a configuration inside a context. | ||
const configurationKey contextKey = 1 | ||
|
||
// NewContext returns a new context that carries a configuration. | ||
func NewContext(ctx context.Context, cfg Configuration) context.Context { | ||
return context.WithValue(ctx, configurationKey, cfg) | ||
} | ||
|
||
// FromContext returns the configuration stored in ctx, if any. | ||
func FromContext(ctx context.Context) (Configuration, bool) { | ||
cfg, ok := ctx.Value(configurationKey).(Configuration) | ||
return cfg, ok | ||
} | ||
|
||
// EOS |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Tideland Go Cells - Example - Documentation | ||
// | ||
// Copyright (C) 2010-2017 Frank Mueller / Tideland / Oldenburg / Germany | ||
// | ||
// All rights reserved. Use of this source code is governed | ||
// by the new BSD license. | ||
|
||
// Package worldchange implements the main program of the | ||
// Tideland Go Cells example. | ||
package main | ||
|
||
//EOF |
Oops, something went wrong.