Giter VIP home page Giter VIP logo

example-mp-solution's Introduction

Example-MP-Solution

An example solution to MP assignments in CSCI3359

Note: This solution is only tangentially related to the assignment and has almost no reflection on the steps you need to take to solve MP0


To Run

Unlike MP0, this example uses goroutines instead of multiprocess parallelism, so it can be run relatively easily.

go run main.go -f example.json

EVEN BETTER build your go files for darwin/amd64 and include the executable in your final solution. This is the architecture of my laptop and will allow me to easily run your solution without installing the dependencies you used.

export GOOS=darwin 
export GOARCH=amd64 
go build main.go

Then to run it, use

./Example-MP-Solution -f example.json

should produce the following output:

Title: Soll ich heute etwas Brot kaufen?
To: H. Muster
From: F. Muster
Date: 2018-01-22 14:28:00 +0000 GMT
Content: H- ich gehe gerade zum Laden. Brauchen wir Brot?
         -F Muster

Structure and Design

Message

There is a message struct in /message/message.go which contains the following fields:

type Message struct{
	To string
	From string
	Title string
	Content string
	Date time.Time
}

It can also initialize a Message from a JSON file via MessageFromJsonFile.

Note: the Date field in the JSON file must conform to Jan 2, 2006 at 3:04pm (MST) format.

Processes

Code can be found in /processes/

To simulate MP0, I created two mock processes with their own wrappers of Message. ProcessA is responsible for sending an initialized message over a channel to ProcessB, which is responsible for receiving the message and printing it.

Since we want to simulate TCP communication, I'm using channels with goroutines.

ProcessA is created from a JSON file via ProcessAFromJsonFile and ProcessB can remain unitialized as its message field gets populated from the channel.

example-mp-solution's People

Contributors

dariusrussellkish avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.