当前位置: 首页>>代码示例>>Golang>>正文


Golang Function.Runtime方法代码示例

本文整理汇总了Golang中github.com/apex/apex/function.Function.Runtime方法的典型用法代码示例。如果您正苦于以下问题:Golang Function.Runtime方法的具体用法?Golang Function.Runtime怎么用?Golang Function.Runtime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/apex/apex/function.Function的用法示例。


在下文中一共展示了Function.Runtime方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: Run

// Run adds the shim when runtime is "golang".
func (p *Plugin) Run(hook function.Hook, fn *function.Function) error {
	if hook != function.OpenHook || fn.Runtime != "golang" {
		return nil
	}

	fn.Shim = true
	fn.Runtime = "nodejs"
	fn.Hooks.Build = "GOOS=linux GOARCH=amd64 go build -o main main.go"
	fn.Hooks.Clean = "rm -f main"

	return nil
}
开发者ID:pilwon,项目名称:apex,代码行数:13,代码来源:golang.go

示例2: Open

// Open adds python defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != "python" {
		return nil
	}

	fn.Runtime = "python2.7"

	if fn.Handler == "" {
		fn.Handler = "main.handle"
	}

	return nil
}
开发者ID:kujohn,项目名称:apex,代码行数:14,代码来源:python.go

示例3: Open

// Open adds python defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

	fn.Runtime = RuntimeCanonical

	if fn.Handler == "" {
		fn.Handler = "main.handle"
	}

	return nil
}
开发者ID:elizar,项目名称:apex,代码行数:14,代码来源:python.go

示例4: Run

// Run specifies python defaults.
func (p *Plugin) Run(hook function.Hook, fn *function.Function) error {
	if hook != function.OpenHook || fn.Runtime != "python" {
		return nil
	}

	fn.Runtime = "python2.7"

	if fn.Handler == "" {
		fn.Handler = "main.handle"
	}

	return nil
}
开发者ID:pilwon,项目名称:apex,代码行数:14,代码来源:python.go

示例5: Open

// Open adds the shim and golang defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

	if fn.Hooks.Build == "" {
		fn.Hooks.Build = "GOOS=linux GOARCH=amd64 go build -o main main.go"
	}

	fn.Shim = true
	fn.Runtime = nodejs.Runtime
	fn.Hooks.Clean = "rm -f main"

	return nil
}
开发者ID:sirodoht,项目名称:apex,代码行数:16,代码来源:golang.go

示例6: Open

// Open adds java defaults.
func (p *Plugin) Open(fn *function.Function) error {
	if fn.Runtime != Runtime {
		return nil
	}

	fn.Runtime = RuntimeCanonical

	if fn.Handler == "" {
		fn.Handler = "lambda.Main::handler"
	}

	fn.Hooks.Clean = "mvn clean"

	return nil
}
开发者ID:elizar,项目名称:apex,代码行数:16,代码来源:java.go

示例7: Run

// Run checks for files in the function directory to infer its runtime.
func (p *Plugin) Run(hook function.Hook, fn *function.Function) error {
	if hook != function.OpenHook || fn.Runtime != "" {
		return nil
	}

	fn.Log.Debug("inferring runtime")

	for name, runtime := range p.Files {
		if _, err := os.Stat(filepath.Join(fn.Path, name)); err == nil {
			fn.Log.WithField("runtime", runtime).Debug("inferred runtime")
			fn.Runtime = runtime
			return nil
		}
	}

	return nil
}
开发者ID:pilwon,项目名称:apex,代码行数:18,代码来源:inference.go

示例8: Build

// Build adds the jar contents to zipfile.
func (p *Plugin) Build(fn *function.Function, zip *archive.Zip) error {
	if fn.Runtime != Runtime {
		return nil
	}
	fn.Runtime = RuntimeCanonical

	fn.Log.Debugf("searching for JAR (%s) in directories: %s", jarFile, strings.Join(jarSearchPaths, ", "))
	expectedJarPath := findJar(fn.Path)
	if expectedJarPath == "" {
		return errors.New("Expected jar file not found")
	}
	fn.Log.Debugf("found jar path: %s", expectedJarPath)

	fn.Log.Debug("appending compiled files")
	reader, err := azip.OpenReader(expectedJarPath)
	if err != nil {
		return err
	}
	defer reader.Close()

	for _, file := range reader.File {
		r, err := file.Open()
		if err != nil {
			return err
		}

		b, err := ioutil.ReadAll(r)
		if err != nil {
			return err
		}
		r.Close()

		zip.AddBytes(file.Name, b)
	}

	return nil
}
开发者ID:DavidTPate,项目名称:apex,代码行数:38,代码来源:java.go


注:本文中的github.com/apex/apex/function.Function.Runtime方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。