Giter Site home page Giter Site logo

Comments (1)

weikanglim avatar weikanglim commented on August 22, 2024

I think we're saying we want the HTTP server to strictly interact using "actions" and maybe we want the same type of system that allows you to attach actions to commands, or to server routes.

I do think this works in a world where the web server exposes the same endpoints as the command and we don't expect these two entry points to be too different. One caveat is that I have seen something play out quite differently when working on IDE integration in VS. We actually want the server to expose more than the CLI. This means exposing the very core business logic. In this world, having less layers and being able to just use any piece of code is a more important in my mind.

Just as an illustration, the only time we use actions in vsrpc is in environment_service_deploy.go.

With all that being said, I do think there's room for improvement here since we have started vsrpc consumption of azd. Looking at our current example:

 // simulate cmd registration of flags and args
ioc.RegisterInstance[*cmd.ProvisionFlags](container.NestedContainer, provisionFlags)
ioc.RegisterInstance[*cmd.DeployFlags](container.NestedContainer, deployFlags)
ioc.RegisterInstance[[]string](container.NestedContainer, []string{})

 // simulate cmd registration of actions by a name
container.MustRegisterNamedTransient("provisionAction", cmd.NewProvisionAction)
container.MustRegisterNamedTransient("deployAction", cmd.NewDeployAction)

// reference action by name
var c struct {
  deployAction    actions.Action `container:"name"`
  provisionAction actions.Action `container:"name"`
}

if err := container.Fill(&c); err != nil {
return nil, err
}

c.provisionAction.Run()

It could be more natural to use an action as a class object:

provisionAction := cmd.ProvisionAction{envName: environmentName}

// resolve DI dependencies
if err := container.Fill(&provisionAction); err != nil {
		return nil, err
}

provisionAction.Run()

from azure-dev.

Related Issues (20)

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.