Giter Club home page Giter Club logo

droplets's Introduction

Hi there 👋

I am Shivaprasad Bhat. A Software Engineer (Since 2016) from India.

  • ♥️ I love building interesting things. They may not always be useful or unique 😁. Feel free to checkout my repositories.

  • 🏗️ I build SaaS tools in my free time

  • 🤩 Apart from tech & brain things, I also watch a lot of movies & play a lot of Arma 3 (King of the Hill mainly. Add me on Steam if you know what I am talking about ) 😎.

  • ✍️ I blog very rarely at https://spy16.in


📡 LinkedIn | E-mail | Website

droplets's People

Contributors

fossabot avatar gromas avatar skorotkiewicz avatar spy16 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

droplets's Issues

Use log.Print, not log.Fatal in the main

@spy16 Also I noticed that defer closeSession() wouldn't execute in the main.
As Fatalf logs the error and then calls os.Exit(1).

defer closeSession()

if err := srv.ListenAndServe(); err != nil {
		lg.Fatalf("http server exited: %s", err) // os.Exit(1) doesn't care about defer
	}

I think it's better to do this

if err := srv.ListenAndServe(); err != nil {
		lg.Printf("http server exited: %s", err) // Print instead
}
defer os.Exit(1)
defer closeSession() // this executes first 

Another option would be to use panic() instead of lg.Fatalf() every where, and then at the bottom of main we could recover panics...

db, closeSession, err := mongo.Connect(cfg.MongoURI, true)
if err != nil {
  panic("failed to connect to mongodb: " + err)
}

// do the same for server and every where else
if err := srv.ListenAndServe(); err != nil {
		panic("http server exited: " + err)
}

// Recover all panics 
defer func() {
        if r := recover(); r != nil {
            closeSession()
            //.. add more clean ups here if needed (we have access to all the functions declared  higher)
            lg.Fatalf(r)  
          
        }
  }()

This methods creates a centralised place for our clean ups, but it does require to use panic for every error that occurs in the main. So it's not very clean, and it kind of goes against the purpose of panic... thus I think method 1 is better.
What do you think?

Unit tests

Unit tests are mandatory for this project to act as a reference.

Search doesn't show

Hi.
After installing and running the application whenever I search the anything in the query.
http://localhost:8080/search?query=k
This shows "404 page doesn't show"
I am looking at the controller in the .go file and also template .tpl file, but I couldn't find it.
Thanks

Docker-compose build fails due to /x/term redeclaration

Pulling master and running docker-compose up fails at the following step

go: downloading golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf

# golang.org/x/term
/go/pkg/mod/golang.org/x/[email protected]/term_unix_linux.go:9:7: ioctlReadTermios redeclared in this block
        previous declaration at /go/pkg/mod/golang.org/x/[email protected]/term_unix_aix.go:9:26
/go/pkg/mod/golang.org/x/[email protected]/term_unix_linux.go:10:7: ioctlWriteTermios redeclared in this block
        previous declaration at /go/pkg/mod/golang.org/x/[email protected]/term_unix_aix.go:10:27
make: *** [Makefile:20: vet] Error 2
ERROR: Service 'droplets' failed to build : The command '/bin/sh -c CGO_ENABLED=0 make setup all' returned a non-zero code: 2

General question about the Dependency Rule

If a layer needs to import from an inner layer, should it only import something from their next inner layer or is it ok to "jump over" inner layers and import from there? For example, is it ok for the interface layer to import from the domain layer (skipping over the usecase layer)?

Design documentation

  • conventions followed
  • advantages/disadvantages of conventions
  • exceptions where convention is not followed

Embedded database instead of Mongo?

Given the simple design of the stores and the goal of helping new developers structure their app; I would consider moving off MongoDB onto BBolt, GoLevelDB, Badger, or one of the many other embedded databases.

There are many helper libraries like Bolthold or Storm which can serve as higher-level access helpers.

I have demo repo with some benchmarks and usage samples here.

ListenAndServe() needs to panic

Hi, I'm new to GoLang. But looking at the code, I think that ListenAndServe() needs to fatal log that will call panic and stop the programme. If ListenAndServe() is broken from the get go, take ListenAndServeTLS(certFile, keyFile), if something goes wrong with certFile then the program should crash, not return an error that we would only know about when we send an incoming signal (to start graceful shutdown). What do you think?

func (gss *Server) ListenAndServe() error {
	go func() {
		gss.server.Addr = gss.Addr
		if err := gss.server.ListenAndServe(); err != http.ErrServerClosed {
			// gss.err = err ---> no need for this
                        log.Fatal(err)  //  logs the error and calls panic
		}
	}()
	return gss.waitForShutdown()
}

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.