From 64a675764ae331273e7ad8e4bcbc32d82394a006 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Sat, 3 Sep 2016 12:30:28 -0400 Subject: [PATCH 1/8] Marking undone pattern documentation as TODO and moving files to match naming conventions. --- README.md | 86 +++++++++---------- .../bounded_parallelism.go | 0 .../md5.go => concurrency/parallelism.go | 0 .../pool.go => creational/object_pool.go | 0 .../circuitbreaker.go | 0 5 files changed, 43 insertions(+), 43 deletions(-) rename bounded_parallelism/md5.go => concurrency/bounded_parallelism.go (100%) rename parallelism/md5.go => concurrency/parallelism.go (100%) rename object_pool/pool.go => creational/object_pool.go (100%) rename {circuitbreaker => stability}/circuitbreaker.go (100%) diff --git a/README.md b/README.md index 8b694da..0e6be91 100644 --- a/README.md +++ b/README.md @@ -15,63 +15,63 @@ __Creational Patterns__: | Pattern | Description | |:-------:| ----------- | -| [Abstract Factory](abstract_factory.go) | Provides an interface for creating families of releated objects | -| [Builder](builder/builder.go) | Builds a complex object using simple objects | -| [Factory Method](factory_method.go) | Defers instantiation of an object to a specialized function for creating instances | -| [Object Pool](object_pool/pool.go) | Instantiates and maintains a group of objects instances of the same type | +| TODO: [Abstract Factory](creational/abstract_factory.md) | Provides an interface for creating families of releated objects | +| TODO: [Builder](creational/builder.md) | Builds a complex object using simple objects | +| TODO: [Factory Method](creational/factory.md) | Defers instantiation of an object to a specialized function for creating instances | +| TODO: [Object Pool](creational/object_pool.gp) | Instantiates and maintains a group of objects instances of the same type | | [Singleton](creational/singleton.md) | Restricts instantiation of a type to one object | __Structural Patterns__: | Pattern | Description | |:-------:| ----------- | -| [Adapter](adapter.go) | Adapts otherwise incompatible interfaces to work together by adapting one to the other | -| [Bridge](bridge.go) | Decouples an interface from its implementation so that the two can vary independently | -| [Composite](composite.go) | Encapsulates and provides access to a number of different objects | +| TODO: [Adapter](structural/.md) | Adapts otherwise incompatible interfaces to work together by adapting one to the other | +| TODO: [Bridge](structural/bridge.md) | Decouples an interface from its implementation so that the two can vary independently | +| TODO: [Composite](structural/composite.md) | Encapsulates and provides access to a number of different objects | | [Decorator](structural/decorator.md) | Adds behavior to an object, statically or dynamically | -| [Facade](facade.go) | Uses one type as an API to a number of others | -| [Flyweight](flyweight.go) | Reuses existing instances of objects with similar/identical state to minimize resource usage | -| [Model View Controller](mvc.go) | Divides an app into three interconnected parts to separate internal representation from presentation to user | -| [Proxy](proxy.go) | Provides a surrogate for an object to control it's actions | +| TODO: [Facade](structural/facade.md) | Uses one type as an API to a number of others | +| TODO: [Flyweight](structural/flyweight.md) | Reuses existing instances of objects with similar/identical state to minimize resource usage | +| TODO: [Model View Controller](structural/model_view_controller.md) | Divides an app into three interconnected parts to separate internal representation from presentation to user | +| TODO: [Proxy](structural/proxy.md) | Provides a surrogate for an object to control it's actions | __Behavioral Patterns__: | Pattern | Description | |:-------:| ----------- | -| [Chain of Responsibility](chain_of_responsibility.go) | Avoids coupling a sender to receiver by giving more than object a chance to handle the request | -| [Command](command.go) | Bundles a command and arguments to call later | -| [Mediator](mediator.go) | Connects objects and acts as a proxy | -| [Memento](memento.go) | Generate an opaque token that can be used to go back to a previous state | -| [Observer](observer.go) | Provide a callback for notification of events/changes to data | -| [Registry](registry.go) | Keep track of all subclasses of a given class | -| [State](state.go) | Encapsulates varying behavior for the same object based on its internal state | +| TODO: [Chain of Responsibility](behavioral/chain_of_responsibility.md) | Avoids coupling a sender to receiver by giving more than object a chance to handle the request | +| TODO: [Command](behavioral/command.md) | Bundles a command and arguments to call later | +| TODO: [Mediator](behavioral/mediator.md) | Connects objects and acts as a proxy | +| TODO: [Memento](behavioral/memento.md) | Generate an opaque token that can be used to go back to a previous state | +| TODO: [Observer](behavioral/observer.md) | Provide a callback for notification of events/changes to data | +| TODO: [Registry](behavioral/registry.md) | Keep track of all subclasses of a given class | +| TODO: [State](behavioral/state.md) | Encapsulates varying behavior for the same object based on its internal state | | [Strategy](behavioral/strategy.md) | Enables an algorithm's behavior to be selected at runtime | -| [Template](template.go) | Defines a skeleton class which defers some methods to subclasses | -| [Visitor](visitor.go) | Separates an algorithm from an object on which it operates | +| TODO: [Template](behavioral/template.md) | Defines a skeleton class which defers some methods to subclasses | +| TODO: [Visitor](behavioral/visitor.md) | Separates an algorithm from an object on which it operates | __Synchronization Patterns__: | Pattern | Description | |:-------:| ----------- | -| [Condition Variable](condition_variable.go) | Provides a mechanism for threads to temporarily give up access in order to wait for some condition | -| [Lock/Mutex](mutex/mutex.go) | Enforces mutual exclusion limit on a resource to gain exclusive access | -| [Monitor](monitor.go) | Combination of mutex and condition variable patterns | -| [Read-Write Lock](read_write_lock.go) | Allows parallel read access, but only exclusive access on write operations to a resource | +| TODO: [Condition Variable](synchronization/condition_variable.md) | Provides a mechanism for threads to temporarily give up access in order to wait for some condition | +| TODO: [Lock/Mutex](synchronization/mutex.md) | Enforces mutual exclusion limit on a resource to gain exclusive access | +| TODO: [Monitor](synchronization/monitor.md) | Combination of mutex and condition variable patterns | +| TODO: [Read-Write Lock](synchronization/read_write_lock.md) | Allows parallel read access, but only exclusive access on write operations to a resource | | [Semaphore](synchronization/semaphore.md) | Allows controlling access to a common resource | __Concurrency Patterns__: | Pattern | Description | |:-------:| ----------- | -| [N-Barrier](barrier.go) | Prevents a process from proceeding until all N processes reach to the barrier | -| [Bounded Parallelism](bounded_parallelism/md5.go) | Completes large number of indenpendent tasks with resource limits | -| [Broadcast](broadcast.go) | Transfers a message to all recipients simultaneously | -| [Coroutines](coroutine/coroutine.go) | Subroutines that allow suspending and resuming execution at certain locations | -| [Generators](generator.go) | Yields a sequence of values one at a time | -| [Reactor](reactor.go) | Demultiplexes service requests delivered concurrently to a service handler and dispatches them syncronously to the associated request handlers | -| [Parallelism](parallelism/md5.go) | Completes large number of indenpendent tasks | -| [Producer Consumer](producer_consumer.go) | Separates tasks from task executions | -| [Scheduler](scheduler.go) | Orchestrates steps to be performed as part of a task | +| TODO: [N-Barrier](concurrency/barrier.md) | Prevents a process from proceeding until all N processes reach to the barrier | +| [Bounded Parallelism](concurrency/bounded_parallelism.md) | Completes large number of indenpendent tasks with resource limits | +| TODO: [Broadcast](concurrency/broadcast.md) | Transfers a message to all recipients simultaneously | +| TODO: [Coroutines](concurrency/coroutine.md) | Subroutines that allow suspending and resuming execution at certain locations | +| TODO: [Generators](concurrency/generator.md) | Yields a sequence of values one at a time | +| TODO: [Reactor](concurrency/reactor.md) | Demultiplexes service requests delivered concurrently to a service handler and dispatches them syncronously to the associated request handlers | +| [Parallelism](concurrency/parallelism.md) | Completes large number of indenpendent tasks | +| TODO: [Producer Consumer](concurrency/producer_consumer.md) | Separates tasks from task executions | +| TODO: [Scheduler](concurrency/scheduler.md) | Orchestrates steps to be performed as part of a task | __Messaging Patterns__: @@ -79,26 +79,26 @@ __Messaging Patterns__: |:-------:| ----------- | | [Fan-In](messaging/fan_in.md) | Funnels tasks to a work sink (e.g. server) | | [Fan-Out](messaging/fan_out.md) | Distributes tasks amongs workers (e.g. producer) | -| [Futures & Promises](futures_promises.go) | Acts as a place-holder of a result that is initally unknown for synchronization purposes | +| TODO: [Futures & Promises](messaging/futures_promises.md) | Acts as a place-holder of a result that is initally unknown for synchronization purposes | | [Publish/Subscribe](messaging/publish_subscribe.md) | Passes information to a collection of recipients who subscribed to a topic | -| [Push & Pull](push_pull.go) | Distributes messages to multiple workers, arranged in a pipeline | +| TODO: [Push & Pull](messaging/push_pull.md) | Distributes messages to multiple workers, arranged in a pipeline | __Stability Patterns__: | Pattern | Description | |:-------:| ----------- | -| [Bulkheads](bulkhead.go) | Enforces a principle of failure containment (i.e. prevents cascading failures) | -| [Circuit-Breaker](circuitbreaker/circuit_breaker.go) | Stops the flow of the requests when requests are likely to fail | -| [Deadline](deadline.go) | Allows clients to stop waiting for a response once the probability of response becomes low (e.g. after waiting 10 seconds for a page refresh)| -| [Fail-Fast](fail_fast.go) | Checks the availability of required resources at the start of a request and fails if the requirements are not satisfied | -| [Handshaking](handshaking.go) | Asks a component if it can take any more load, if it can't the request is declined | -| [Steady-State](steady_state.go) | For every service that accumulates a resource, some other service must recycle that resource | +| TODO: [Bulkheads](stability/bulkhead.md) | Enforces a principle of failure containment (i.e. prevents cascading failures) | +| [Circuit-Breaker](stability/circuit_breaker.go) | Stops the flow of the requests when requests are likely to fail | +| TODO: [Deadline](stability/deadline.md) | Allows clients to stop waiting for a response once the probability of response becomes low (e.g. after waiting 10 seconds for a page refresh)| +| TODO: [Fail-Fast](stability/fail_fast.md) | Checks the availability of required resources at the start of a request and fails if the requirements are not satisfied | +| TODO: [Handshaking](stability/handshaking.md) | Asks a component if it can take any more load, if it can't the request is declined | +| TODO: [Steady-State](stability/steady_state.md) | For every service that accumulates a resource, some other service must recycle that resource | __Profiling Patterns__: | Pattern | Description | |:-------:| ----------- | -| [Timing Functions](timing.go) | Wraps a function and logs the execution | +| TODO: [Timing Functions](profiling/timing.md) | Wraps a function and logs the execution | __Idioms__: @@ -110,7 +110,7 @@ __Anti-Patterns__: | Pattern | Description | |:-------:| ----------- | -| [Cascading Failures]() | A failure in a system of interconnected parts in which the failure of a part causes a domino effect | +| TODO: [Cascading Failures](antipatterns/cascading_failures.md) | A failure in a system of interconnected parts in which the failure of a part causes a domino effect | __Other Patterns__: diff --git a/bounded_parallelism/md5.go b/concurrency/bounded_parallelism.go similarity index 100% rename from bounded_parallelism/md5.go rename to concurrency/bounded_parallelism.go diff --git a/parallelism/md5.go b/concurrency/parallelism.go similarity index 100% rename from parallelism/md5.go rename to concurrency/parallelism.go diff --git a/object_pool/pool.go b/creational/object_pool.go similarity index 100% rename from object_pool/pool.go rename to creational/object_pool.go diff --git a/circuitbreaker/circuitbreaker.go b/stability/circuitbreaker.go similarity index 100% rename from circuitbreaker/circuitbreaker.go rename to stability/circuitbreaker.go From 804615ceec9c14d8271748824f6619d2c4d69983 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Sat, 3 Sep 2016 12:33:33 -0400 Subject: [PATCH 2/8] Some links are .go and not .md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0e6be91..c886ee4 100644 --- a/README.md +++ b/README.md @@ -64,12 +64,12 @@ __Concurrency Patterns__: | Pattern | Description | |:-------:| ----------- | | TODO: [N-Barrier](concurrency/barrier.md) | Prevents a process from proceeding until all N processes reach to the barrier | -| [Bounded Parallelism](concurrency/bounded_parallelism.md) | Completes large number of indenpendent tasks with resource limits | +| [Bounded Parallelism](concurrency/bounded_parallelism.go) | Completes large number of indenpendent tasks with resource limits | | TODO: [Broadcast](concurrency/broadcast.md) | Transfers a message to all recipients simultaneously | | TODO: [Coroutines](concurrency/coroutine.md) | Subroutines that allow suspending and resuming execution at certain locations | | TODO: [Generators](concurrency/generator.md) | Yields a sequence of values one at a time | | TODO: [Reactor](concurrency/reactor.md) | Demultiplexes service requests delivered concurrently to a service handler and dispatches them syncronously to the associated request handlers | -| [Parallelism](concurrency/parallelism.md) | Completes large number of indenpendent tasks | +| [Parallelism](concurrency/parallelism.go) | Completes large number of indenpendent tasks | | TODO: [Producer Consumer](concurrency/producer_consumer.md) | Separates tasks from task executions | | TODO: [Scheduler](concurrency/scheduler.md) | Orchestrates steps to be performed as part of a task | @@ -88,7 +88,7 @@ __Stability Patterns__: | Pattern | Description | |:-------:| ----------- | | TODO: [Bulkheads](stability/bulkhead.md) | Enforces a principle of failure containment (i.e. prevents cascading failures) | -| [Circuit-Breaker](stability/circuit_breaker.go) | Stops the flow of the requests when requests are likely to fail | +| [Circuit-Breaker](stability/circuitbreaker.go) | Stops the flow of the requests when requests are likely to fail | | TODO: [Deadline](stability/deadline.md) | Allows clients to stop waiting for a response once the probability of response becomes low (e.g. after waiting 10 seconds for a page refresh)| | TODO: [Fail-Fast](stability/fail_fast.md) | Checks the availability of required resources at the start of a request and fails if the requirements are not satisfied | | TODO: [Handshaking](stability/handshaking.md) | Asks a component if it can take any more load, if it can't the request is declined | From 40b4ab5963ff1a51fa619c70047df9b24dff3318 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Sun, 4 Sep 2016 13:36:39 -0400 Subject: [PATCH 3/8] Parallelism markdown. --- concurrency/parallelism.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 concurrency/parallelism.md diff --git a/concurrency/parallelism.md b/concurrency/parallelism.md new file mode 100644 index 0000000..c9aeab8 --- /dev/null +++ b/concurrency/parallelism.md @@ -0,0 +1,7 @@ +# Parallelism Pattern + +[Parallelism](https://blog.golang.org/pipelines#TOC_8.) allows multiple "jobs" or tasks to be run concurrently and asynchronously. + +# Implementation and Example + +An example showing implementation and usage can be found in [parallelism.go](parallelism.go). \ No newline at end of file From ce288860afac8b0f0d76cc5ab626eb69921626da Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Sun, 4 Sep 2016 13:36:54 -0400 Subject: [PATCH 4/8] Bounded parallelism markdown. --- concurrency/bounded_parallelism.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 concurrency/bounded_parallelism.md diff --git a/concurrency/bounded_parallelism.md b/concurrency/bounded_parallelism.md new file mode 100644 index 0000000..8f1429c --- /dev/null +++ b/concurrency/bounded_parallelism.md @@ -0,0 +1,7 @@ +# Bounded Parallelism Pattern + +[Bounded parallelism](https://blog.golang.org/pipelines#TOC_9.) is similar to [parallelism](parallelism.md), but allows limits to be placed on allocation. + +# Implementation and Example + +An example showing implementation and usage can be found in [bounded_parallelism.go](bounded_parallelism.go). \ No newline at end of file From a05848d1edac8a5356685c0ae6387bdee3ff8b8a Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Sun, 4 Sep 2016 13:39:52 -0400 Subject: [PATCH 5/8] Object pool markdown. --- creational/object_pool.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 creational/object_pool.md diff --git a/creational/object_pool.md b/creational/object_pool.md new file mode 100644 index 0000000..e2770e1 --- /dev/null +++ b/creational/object_pool.md @@ -0,0 +1,7 @@ +# Object Pool Pattern + +The [object pool design pattern](https://en.wikipedia.org/wiki/Object_pool_pattern) allows multiple instances to be kept in a collection ("pool") in order to have already been initialized when other instances are ready to use them. + +# Implementation and Example + +An example with implementation and usage can be found in [object_pool.go](object_pool.go). \ No newline at end of file From 5ee14c58f35be4c558eafadd8abfce51b975fac3 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Sun, 4 Sep 2016 13:43:28 -0400 Subject: [PATCH 6/8] Changing all links to markdown and fixing typos --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index c886ee4..d380ecf 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ __Creational Patterns__: | TODO: [Abstract Factory](creational/abstract_factory.md) | Provides an interface for creating families of releated objects | | TODO: [Builder](creational/builder.md) | Builds a complex object using simple objects | | TODO: [Factory Method](creational/factory.md) | Defers instantiation of an object to a specialized function for creating instances | -| TODO: [Object Pool](creational/object_pool.gp) | Instantiates and maintains a group of objects instances of the same type | +| [Object Pool](creational/object_pool.md) | Instantiates and maintains a group of objects instances of the same type | | [Singleton](creational/singleton.md) | Restricts instantiation of a type to one object | __Structural Patterns__: @@ -64,12 +64,12 @@ __Concurrency Patterns__: | Pattern | Description | |:-------:| ----------- | | TODO: [N-Barrier](concurrency/barrier.md) | Prevents a process from proceeding until all N processes reach to the barrier | -| [Bounded Parallelism](concurrency/bounded_parallelism.go) | Completes large number of indenpendent tasks with resource limits | +| [Bounded Parallelism](concurrency/bounded_parallelism.md) | Completes large number of independent tasks with resource limits | | TODO: [Broadcast](concurrency/broadcast.md) | Transfers a message to all recipients simultaneously | | TODO: [Coroutines](concurrency/coroutine.md) | Subroutines that allow suspending and resuming execution at certain locations | | TODO: [Generators](concurrency/generator.md) | Yields a sequence of values one at a time | | TODO: [Reactor](concurrency/reactor.md) | Demultiplexes service requests delivered concurrently to a service handler and dispatches them syncronously to the associated request handlers | -| [Parallelism](concurrency/parallelism.go) | Completes large number of indenpendent tasks | +| [Parallelism](concurrency/parallelism.md) | Completes large number of independent tasks | | TODO: [Producer Consumer](concurrency/producer_consumer.md) | Separates tasks from task executions | | TODO: [Scheduler](concurrency/scheduler.md) | Orchestrates steps to be performed as part of a task | @@ -78,8 +78,8 @@ __Messaging Patterns__: | Pattern | Description | |:-------:| ----------- | | [Fan-In](messaging/fan_in.md) | Funnels tasks to a work sink (e.g. server) | -| [Fan-Out](messaging/fan_out.md) | Distributes tasks amongs workers (e.g. producer) | -| TODO: [Futures & Promises](messaging/futures_promises.md) | Acts as a place-holder of a result that is initally unknown for synchronization purposes | +| [Fan-Out](messaging/fan_out.md) | Distributes tasks among workers (e.g. producer) | +| TODO: [Futures & Promises](messaging/futures_promises.md) | Acts as a place-holder of a result that is initially unknown for synchronization purposes | | [Publish/Subscribe](messaging/publish_subscribe.md) | Passes information to a collection of recipients who subscribed to a topic | | TODO: [Push & Pull](messaging/push_pull.md) | Distributes messages to multiple workers, arranged in a pipeline | From 9d21f856cd7c81d8a4f93c0a2398a67b12aa1b46 Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Sun, 4 Sep 2016 13:52:42 -0400 Subject: [PATCH 7/8] Circuit breaker markdown --- README.md | 2 +- stability/circuit_breaker.md | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 stability/circuit_breaker.md diff --git a/README.md b/README.md index d380ecf..dfec8f7 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ __Stability Patterns__: | Pattern | Description | |:-------:| ----------- | | TODO: [Bulkheads](stability/bulkhead.md) | Enforces a principle of failure containment (i.e. prevents cascading failures) | -| [Circuit-Breaker](stability/circuitbreaker.go) | Stops the flow of the requests when requests are likely to fail | +| [Circuit-Breaker](stability/circuit_breaker.md) | Stops the flow of the requests when requests are likely to fail | | TODO: [Deadline](stability/deadline.md) | Allows clients to stop waiting for a response once the probability of response becomes low (e.g. after waiting 10 seconds for a page refresh)| | TODO: [Fail-Fast](stability/fail_fast.md) | Checks the availability of required resources at the start of a request and fails if the requirements are not satisfied | | TODO: [Handshaking](stability/handshaking.md) | Asks a component if it can take any more load, if it can't the request is declined | diff --git a/stability/circuit_breaker.md b/stability/circuit_breaker.md new file mode 100644 index 0000000..0fb5d7c --- /dev/null +++ b/stability/circuit_breaker.md @@ -0,0 +1,7 @@ +# Circuit Breaker Pattern + +The [circuit breaker design pattern](https://en.wikipedia.org/wiki/Circuit_breaker_design_pattern) is used to detect failures and encapsulates logic of preventing a failure to reoccur constantly. + +# Implementation and Example + +An example of implementation and usage can be found in [circuitbreaker.go](circuitbreaker.go). \ No newline at end of file From ef768c00c42d1af7f0512b5b13d18c6d89060c7a Mon Sep 17 00:00:00 2001 From: Anthony Atkinson Date: Sun, 4 Sep 2016 13:53:00 -0400 Subject: [PATCH 8/8] Attempt at correct travis YML file for checking for .go links. --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..9dad772 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,2 @@ +script: + - exit $(grep -c ".go)" README.md) \ No newline at end of file