5
5
# Go Patterns [ ![ Travis Widget]] [ Travis ] [ ![ Awesome Widget]] [ Awesome ] [ ![ License Widget]] [ License ]
6
6
[ Awesome Widget ] : https://img.shields.io/badge/awesome-%E2%9C%93-ff69b4.svg?style=flat-square
7
7
[ Awesome ] : https://github.com/sindresorhus/awesome
8
- [ Travis Widget ] : https://img.shields.io/travis/tmrts/awesome-google-cloud .svg?style=flat-square
8
+ [ Travis Widget ] : https://img.shields.io/travis/tmrts/go-patterns .svg?style=flat-square
9
9
[ Travis ] : http://travis-ci.org/tmrts/go-patterns
10
10
[ License Widget ] : https://img.shields.io/badge/license-Creative%20Commons%204.0-E91E63.svg?style=flat-square
11
11
[ License ] : http://creativecommons.org/licenses/by/4.0/
12
12
A curated collection of idiomatic design & application patterns for Go language.
13
13
14
+ For use cases please see the test files (files suffixed with _ test).
15
+
14
16
__ Creational Patterns__ :
15
17
16
18
| Pattern | Description |
17
19
| :-------:| ----------- |
18
20
| [ Abstract Factory] ( abstract_factory.go ) | use a generic function with specific factories |
19
- | [ Borg Singleton] ( borg_singleton .go) | a singleton with shared-state among instances |
20
- | [ Builder] ( builder.go ) | instead of using multiple constructors, builder object receives parameters and returns constructed objects |
21
+ | [ Singleton] ( singleton/singleton .go) | Restricts instantiation of a class to one object |
22
+ | [ Builder] ( builder/builder .go ) | instead of using multiple constructors, builder object receives parameters and returns constructed objects |
21
23
| [ Factory Method] ( factory_method.go ) | delegate a specialized function/method to create instances |
22
24
| [ Lazy Evaluation] ( lazy_evaluation.go ) | lazily-evaluated property pattern in Go |
23
- | [ Object Pool] ( object_pool.go ) | preinstantiate and maintain a group of instances of the same type |
24
- | [ Prototype] ( prototype.go ) | use a factory and clones of a prototype for new instances (if instantiation is expensive) |
25
+ | [ Object Pool] ( object_pool/pool.go ) | Instantiates and maintains a group of objects instances of the same type |
25
26
26
27
__ Structural Patterns__ :
27
28
@@ -47,23 +48,22 @@ __Behavioral Patterns__:
47
48
| [ Mediator] ( mediator.go ) | an object that knows how to connect other objects and act as a proxy |
48
49
| [ Memento] ( memento.go ) | generate an opaque token that can be used to go back to a previous state |
49
50
| [ Observer] ( observer.go ) | provide a callback for notification of events/changes to data |
50
- | [ Publish/Subscribe] ( publish_subscribe.go ) | Passes information to a collection of recipients who subscribed to a topic |
51
51
| [ Registry] ( registry.go ) | keep track of all subclasses of a given class |
52
52
| [ Specification] ( specification.go ) | business rules can be recombined by chaining the business rules together using boolean logic |
53
53
| [ State] ( state.go ) | logic is organized into a discrete number of potential states and the next state that can be transitioned to |
54
- | [ Strategy] ( strategy.go ) | Encapsulates an algorithm inside a struct |
54
+ | [ Strategy] ( strategy/strategy .go ) | Encapsulates an algorithm inside a struct |
55
55
| [ Template] ( template.go ) | an object imposes a structure but takes pluggable components |
56
56
| [ Visitor] ( visitor.go ) | invoke a callback for all items of a collection |
57
57
58
58
__ Synchronization Patterns__ :
59
59
60
60
| Pattern | Description |
61
61
| :-------:| ----------- |
62
- | [ Lock/Mutex] ( mutex.go ) | Enforces mutual exclusion limit on accessing a resource |
62
+ | [ Lock/Mutex] ( mutex/mutex .go ) | Enforces mutual exclusion limit on accessing a resource |
63
63
| [ Read-Write Lock] ( read_write_lock.go ) | |
64
64
| [ Condition Variable] ( condition_variable.go ) | |
65
- | [ Monitor] ( monitor.go ) | Combination of mutex and condition patterns |
66
- | [ Semaphore] ( semaphore.go ) | Allows controlling access to a common resource |
65
+ | [ Monitor] ( monitor.go ) | Combination of mutex and condition variable patterns |
66
+ | [ Semaphore] ( semaphore/semaphore .go ) | Allows controlling access to a common resource |
67
67
68
68
__ Concurrency Patterns__ :
69
69
@@ -75,16 +75,25 @@ __Concurrency Patterns__:
75
75
| [ Futures] ( future.go ) | |
76
76
| [ Broadcast] ( broadcast.go ) | |
77
77
| [ Multiplex] ( multiplex.go ) | |
78
- | [ Fan-In] ( fan_in.go ) | |
79
78
| [ Generators] ( generator.go ) | |
80
- | [ Coroutines] ( coroutine.go ) | |
79
+ | [ Coroutines] ( coroutine/coroutine.go ) | |
80
+ | [ Parallelism] ( parallelism/md5.go ) | Completes large number of indenpendent tasks |
81
+ | [ Bounded Parallelism] ( bounded_parallelism/md5.go ) | Completes large number of indenpendent tasks with resource limits |
82
+
83
+ __ Messaging Patterns__ :
84
+ | [ Fan-In] ( fan/fan_in.go ) | Funnels tasks to a work sink (e.g. server) |
85
+ | [ Fan-Out] ( fan/fan_out.go ) | Distributes tasks amongs workers |
86
+ | [ Publish/Subscribe] ( publish_subscribe.go ) | Passes information to a collection of recipients who subscribed to a topic |
87
+ | [ Request & Reply] ( fan ) | |
88
+ | [ Push & Pull] ( fan ) | |
89
+
81
90
82
91
__ Stability Patterns__ :
83
92
84
93
| Pattern | Description |
85
94
| :-------:| ----------- |
86
95
| [ Bulkheads] ( bulkhead.go ) | |
87
- | [ Circuit Breaker] ( circuit_breaker.go ) | |
96
+ | [ Circuit Breaker] ( circuitbreaker/ circuit_breaker.go) | Stops the flow of the requests when requests are likely to fail |
88
97
| [ Deadline] ( deadline.go ) | |
89
98
| [ Fail Fast] ( fail_fast.go ) | |
90
99
| [ Handshaking] ( handshaking.go ) | |
@@ -106,6 +115,7 @@ __Anti-Patterns__:
106
115
107
116
| Pattern | Description |
108
117
| :-------:| ----------- |
118
+ | [ Cascading Failures] ( ) | |
109
119
110
120
__ Other Patterns__ :
111
121
0 commit comments