Giter VIP home page Giter VIP logo

rezoom's People

Contributors

rkosafo avatar rspeele 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  avatar  avatar

rezoom's Issues

Make ServiceContext.GetService take a factory function instead of a type

Here:

override this.GetService<'f, 'a when 'f :> ServiceFactory<'a> and 'f : (new : unit -> 'f)>() =

Requiring this to be a type means that in order for the batch type to be initialized with a parameter, it must be represented by a sub-type. Additionally, this could enable a helper function which allows for simple wrapping of all of this. Is there any reason this couldn't be a constructor function instead?

Motivating Example:

open System
open Rezoom
open Rezoom.Execution

type OrgId = OrgId of Guid
    with static member MakeOrgId () = OrgId (Guid.NewGuid())

type UserId = UserId of Guid
    with static member MakeUserId () = UserId (Guid.NewGuid())

let org1Id = OrgId.MakeOrgId()
let org2Id = OrgId.MakeOrgId()

let orgs = dict [ org1Id, "Org 1"
                  org2Id, "Org 2" ]

let users = dict [ UserId.MakeUserId(), ("User 1", org1Id )
                   UserId.MakeUserId(), ("User 2", org1Id )
                   UserId.MakeUserId(), ("User 3", org1Id )
                   UserId.MakeUserId(), ("User 4", org1Id )
                   UserId.MakeUserId(), ("User 5", org1Id )
                   UserId.MakeUserId(), ("User 6", org2Id )
                   UserId.MakeUserId(), ("User 7", org2Id )
                   UserId.MakeUserId(), ("User 8", org2Id )
                   UserId.MakeUserId(), ("User 9", org2Id )
                   UserId.MakeUserId(), ("User 10", org2Id ) ]

let getOrg id = orgs.[id]
let getUser id = users.[id]

let getOrgs ids = ids |> Seq.map getOrg
let getUsers ids = ids |> Seq.map getUser

type StepBatch<'a, 'b>(runBatch: 'a seq -> 'b seq) =
    let userIds = ResizeArray<'a>()
    let batchResults = lazy (runBatch userIds |> Seq.toArray) 
    
    member this.AddToBatch(i) =
        let index = userIds.Count
        userIds.Add(i)
        fun () -> batchResults.Value.[index]
        
let getCache<'a> () = 
    { new CacheInfo() with
        override this.Category = box typeof<'a>
        override this.Identity = box "ignorefornow"
        override this.Cacheable = true
        override this.DependencyMask = BitMask.Zero
        override this.InvalidationMask = BitMask.Zero
    }

//can't do this

//type Errand<'a, 'b>(arg : UserId, factory: unit->StepBatch<'a, 'b>) =
//    inherit SynchronousErrand<'b>()
//    
//    override this.CacheInfo = getCache<StepBatch<'a, 'b>> ()
//    override this.CacheArgument = box arg
//    
//    override this.Prepare(context : ServiceContext) =
//        let batch = context.GetService<UserStepBatch>(factory)
//        batch.AddToBatch arg
//
//type UserErrand(arg: UserId) = 
//    inherit Errand<UserId, string*OrgId>(arg, fun () -> StepBatch<UserId, string*OrgId>(getUsers) )
//
//type OrgErrand(arg: OrgId) = 
//    inherit Errand<OrgId, string>(arg, fun () -> StepBatch<OrgId, string>(getOrgs))
//
// Can create as many of these as I want trivially now!

//have to do this instead

type UserStepBatch() = inherit StepBatch<UserId, string*OrgId>(getUsers)
type OrgStepBatch() = inherit StepBatch<OrgId, string>(getOrgs)
    
type UserErrand(arg : UserId) =
    inherit SynchronousErrand<string*OrgId>()
    
    override this.CacheInfo = getCache<UserStepBatch> ()
    override this.CacheArgument = box arg
    
    override this.Prepare(context : ServiceContext) =
        let batch = context.GetService<StepLocal<UserStepBatch>, UserStepBatch>()
        batch.AddToBatch arg
        
type OrgErrand(arg : OrgId) =
    inherit SynchronousErrand<string>()
    
    override this.CacheInfo = getCache<OrgStepBatch> ()
    override this.CacheArgument = box arg
    
    override this.Prepare(context : ServiceContext) =
        // Get the batch for this execution step.
        let batch = context.GetService<StepLocal<OrgStepBatch>, OrgStepBatch>()
        // Add ourselves to the batch, return the result getter.
        batch.AddToBatch arg

New logo for ReZoom

I wanted to contribute to ReZoom. I designed a logo for ReZoom. If you like it, I'll send you the files.

reezoom

Move to FsProjects

Hi @rspeele

We're interested in moving this to FsProjects as we have contributors doing improvements and trying to use it in production.

Also we'll need you to add the FsProjects account to the nuget.

Please let me know if you agree and I can give you more details about how to proceed.

Thanks !

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.